write a program to produce the following output;
ABCDEFGFEDCBA
ABCDEF FEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / neeraj kumar
#include<stdio.h>
#include<conio.h>
main()
{
int a,x,n=71,o=70,y=1,c;
clrscr();
for(x=1;x<=7;x++)
{
for(a=65;a<=n;a++) // loop for printing ABCDEFG
printf("%c",a);
if(x==2)
o=70;
for(c=2;c<y;c++) //space loop
printf(" ");
for(a=o;a>=65;a) // loop for printing FEDCBA
printf("%c",a);
printf("
"); // to sta
n;
o;
y=y+2;
}g
etch();
} (g
) Write a program to fill the entire screen with diamond and heart alternatively. The ASCII
value for heart is 3 and that of diamond is 4.
#include<stdio.h>
#include<conio.h>
main()
{
int a, b,c,d;
clrscr();
for(c=1;c<=37;c++)
{
for(d=1;d<=49;d++)
{
for(a=4;a<=4;a++)
{
for(b=3;b<=3;b++)
printf("%c%c ",a,b);
}
}
}
getch();
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / atul wagare
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,m;
for(i=0;i<7;i++)
{
for(j=0;j<7-i;j++)
{
printf("%c",j+65);
}
for(k=1;k<=i*2-1;k++)
{
printf(" ");
}
if(i==0||i==1)
{
for(l=70;l>=65;l--)
{
printf("%c",l);
}
}
else
{
for(l=70-(i-1);l>=65;l--)
{
printf("%c",l);
}
}
//printf("%d %d",j,k);
printf("
");
}
getche();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / shariq
can anyone solve this example by using string??
and is it possible ??
please answer my question ......
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / siddharth shravan jha
//Most Easy Way to Solve this type of questions.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,r,m;
for(i=0;i<7;i++)
{
r=71-i;
for (j=65;j<=r;j++) //ASCII values for A-Z is in range 65-91,i.e.,for A-G is from 65-71
{
printf("%c ",j);
}
for (m=1;m<=i;m++)
{
printf(" ");
}
for (k=r;k>=65;k--)
{
printf(" %c",k);
}
printf("
");
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / karthikeyan ist year cse skc
in()
{
int i,n=65,m=72,f=0,s=-6;
clrscr();
while(m-->=n)
{s+=4;
for(i=n;i<m;i++)
printf("%c ",i);
if(f==0) ++m;
else
for(i=0;i<s;i++) printf(" ");
for(i=m-1;i>=n;i--)
printf("%c ",i);
printf("\n");f=1;
}
getch();
}
| Is This Answer Correct ? | 5 Yes | 6 No |
Answer / smar tass
#include <stdio.h>
int main (void) {
printf('ABCDEFGFEDCBA\nABCDEF FEDCBA\nABCDE EDCBA\nABCD DCBA\nABC CBA\nAB BA\nA A\n');
return 0;
}
| Is This Answer Correct ? | 8 Yes | 14 No |
I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.
void main() { for(; 0 ;) ... { printf("hello"); ... } getch(); }
Explain what are reserved words?
Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)
Explain the difference between malloc() and calloc() function?
Give differences between - new and malloc() , delete and free() ?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }
we have a 3litres jug and a 5 litres jug and no measures on them. using these two jugs how can we measure 4 litres of water?
Is that possible to store 32768 in an int data type variable?
How can you print HELLO WORLD without using "semicolon"?
How to get string length of given string in c?