write a program to produce the following output;
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
Answer Posted / ravinder singh
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n = 1;
for(char i=71; i>=65; i--)
{
for(char j=65;j<=i; j++)
{
cout<<j;
}
if(i!=71)
{
for(int x=2; x<n; x++)
{
cout<<" ";
}
}
if(i==71)
{
for(char k=i-1; k>=65;k--)
{
// if(k==71)
// continue;
cout<<k;
}
}
else if(i==70||i==69||i==68||i==67||i==66||i==65)
{
for(char k=i; k>=65;k--)
{
cout<<k;
}
}
n = n+2;
cout<<"\n";
}
getch();
}
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Is it possible to execute code even after the program exits the main() function?
What are the advantages of Macro over function?
What are the different types of objects used in c?
What is array in C
what is a constant pointer in C
What is the difference between int main and void main in c?
Do you know null pointer?
What is .obj file in c?
How does placing some code lines between the comment symbol help in debugging the code?
What is array in c with example?
Write a program to reverse a given number in c language?
How can I implement sets or arrays of bits?
What are the primitive data types in c?
Tell me what is null pointer in c?
explain how do you use macro?