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
How can you restore a redirected standard stream?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
Is c language still used?
When is the “void” keyword used in a function?
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
Explain continue keyword in c
Dont ansi function prototypes render lint obsolete?
Is null always defined as 0(zero)?
What are the functions to open and close the file in c language?
Can a pointer be null?
What are the preprocessor categories?
Do pointers take up memory?
What are the advantages and disadvantages of a heap?
Is c dynamically typed?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?