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
this is the correct logic..... some syntax mistakes was done
befoe ... nowq it's correct.... thank you
#include<stdio.h>
#include<conio.h>
void logic1(int,int);
void logic2();
void logic3();
void logic4();
int a=0;
void main()
{
int m;
printf("enter the number of lines :");
scanf("%d",&m);
for(int i=1;i<=(m/2+1);i++)
{
printf("\n");
if(i%2!=0)
logic1(i,m);
else
logic2();
}
for(i=1;i<=m/2;i++)
{
printf("\n");
if(i%2!=0)
logic3();
else
logic4();
}
getch();
}
void logic1(int p,int m)
{
a=(m/2+2)-p;
for(int i=a;i>=1;i--)
printf("%d",i);
}
void logic2();
{
a--;
for(int i=1;i<=a;i++)
printf("%d",i);
}
void logic3()
{
a++;
for(int i=a;i>=1;i++)
printf("%d",i);
}
void logic4()
{
a++;
for(int i=1;i<=a;i++)
printf("%d",i);
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
Differentiate call by value and call by reference?
Are comments included during the compilation stage and placed in the EXE file as well?
Explain what standard functions are available to manipulate strings?
How do you print an address?
Can we declare variables anywhere in c?
What is double pointer?
What are the types of type qualifiers in c?
How is actual parameter different from the formal parameter?
write a program to create a sparse matrix using dynamic memory allocation.
Is fortran still used in 2018?
What do you mean by keywords in c?
Why is structure padding done in c?
How to draw the flowchart for structure programs?
What does sizeof return c?
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university