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
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
what are the advantages of a macro over a function?
What is build process in c?
Explain heap and queue.
When is the “void” keyword used in a function?
What is the difference between typedef struct and struct?
How do we make a global variable accessible across files? Explain the extern keyword?
What are the scope of static variables?
How many levels of pointers have?
What math functions are available for integers? For floating point?
Should I learn data structures in c or python?
What does c mean in standard form?
What is the use of sizeof () in c?
How many types of arrays are there in c?
Is there anything like an ifdef for typedefs?