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 / vignesh1988i
DIFFERENT LOGIC
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,p;
printf("enter the limit value");
scanf("%d",&m);
n=m+1;
for(int i=1;i<2*m-1;i++)
{
if(i<=m)
{
n--;
p=0;
}
else
{
n++
p=1;
}
if(i%2==p)
{
for(int j=1;j<n;j++)
printf("%d",j);
}
else
{
for(j=n;j>=1;j--)
printf("%d",j);
}
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
What is the use of getchar functions?
Explain how can a program be made to print the line number where an error occurs?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is typedef?
How many types of functions are there in c?
How pointer is different from array?
Explain the bubble sort algorithm.
What are identifiers in c?
What is wild pointer in c with example?
How to compare array with pointer in c?
What are the advantages of c language?
Why is c platform dependent?
Write a program to generate the Fibinocci Series
What does it mean when the linker says that _end is undefined?
What is indirection?