print the following using nested for loop.
5 4 3 2 1
1 2 3 4
3 2 1
1 2
1
2 1
1 2 3
4 3 2 1
1 2 3 4 5
Answer Posted / harsha
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>1;i=i-2)
{
for(j=i;j>=1;j--)
printf("%d",j);
printf("\n");
for(j=1;j<i;j++)
printf("%d",j);
printf("\n");
}
printf("1");
for(i=2;i<=5;i=i+2)
{
printf("\n");
for(j=i;j>=1;j--)
printf("%d",j);
printf("\n");
for(j=1;j<=i+1;j++)
printf("%d",j);
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
What is a #include preprocessor?
What is the heap?
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
If fflush wont work, what can I use to flush input?
What is a volatile keyword in c?
What is the importance of c in your views?
What is nested structure?
Why isn't it being handled properly?
What is hashing in c language?
Explain can you assign a different address to an array tag?
Can we access the array using a pointer in c language?
When c language was developed?
What are variables c?
How do I create a directory? How do I remove a directory (and its contents)?