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
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
If errno contains a nonzero number, is there an error?
how is the examination pattern?
What are the different categories of functions in c?
What is structure of c program?
What is assert and when would I use it?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
What is sizeof c?
Explain 'bus error'?
Compare and contrast compilers from interpreters.
what do the 'c' and 'v' in argc and argv stand for?
Write a code of a general series where the next element is the sum of last k terms.
What is return type in c?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
Can we use visual studio for c?