Alphabet series – CSKC
Sign In

Search

Solved Problem #CPP#5182    siteicon   siteicon  

Problem Statement - Alphabet series

Write a program to print the following alphabet series up to 7 terms.

C F I L …..

Solution

TC++ #5182

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

char x=’C’;
First character of series is initialized here

for(int i=0; i<7; ++i) 

Here we run the for loop for number of terms to be printed
{
cout<<x<<” “;
This prints each term with a space after wards. since x is a character so it prints the character version only.
x+=3; 
Here the term is added with 3 so that it reaches the next character after 3 positions. since x still remains a character so next printing will also be in character form.
}

Common Errors

  • If x is taken as integer then at the time of printing it has to be typecasted as character.


Share

Created: 2-Dec-2018 22:43 | Updated: 2-Dec-2018 22:43|