Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Differentiate call by value and call by reference?

916


Are comments included during the compilation stage and placed in the EXE file as well?

1029


Explain what standard functions are available to manipulate strings?

1025


How do you print an address?

1212


Can we declare variables anywhere in c?

948


What is double pointer?

950


What are the types of type qualifiers in c?

1032


How is actual parameter different from the formal parameter?

973


write a program to create a sparse matrix using dynamic memory allocation.

4838


Is fortran still used in 2018?

986


What do you mean by keywords in c?

1083


Why is structure padding done in c?

1070


How to draw the flowchart for structure programs?

9260


What does sizeof return c?

1012


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

2004