Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Write a program to print the following alphabet series up to 7 terms.
C F I L …..
Solution
TC++ #5182
Run Output
C F I L O R U
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.