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
how do you programme Carrier Sense Multiple Access
In which header file is the null macro defined?
The __________ attribute is used to announce variables based on definitions of columns in a table?
Explain what standard functions are available to manipulate strings?
Explain how can a program be made to print the line number where an error occurs?
Explain a pre-processor and its advantages.
What is merge sort in c?
What are the different types of control structures?
What are the basic data types associated with c?
formula to convert 2500mmh2o into m3/hr
What is the benefit of using #define to declare a constant?
What is the ANSI C Standard?
How many data structures are there in c?
What is the use of bitwise operator?
What is the full form of getch?