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 / dally

#include<stdio.h>

int main()
{
int i,j,n=5;

for(i=n;i>=1;i--)
{
if(i%2 == 0){
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
else
{
for(j=i;j>=1;j--)
printf("%d",j);
printf("\n");
}
}
for(i=2;i<=5;i++)
{
if(i%2 != 0) {
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
else
{
for(j=i;j>=1;j--)
printf("%d",j);
printf("\n");
}
}
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Whats s or c mean?

963


What is void main ()?

1033


What is your stream meaning?

1149


Explain the difference between call by value and call by reference in c language?

1070


How can I ensure that integer arithmetic doesnt overflow?

1109


What are register variables? What are the advantage of using register variables?

1143


Define circular linked list.

984


What is pointers in c?

1076


write a program to print largest number of each row of a 2D array

2280


What is the meaning of && in c?

975


Explain how do you list a file’s date and time?

1004


How many bytes are occupied by near, far and huge pointers (dos)?

1131


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

1071


How can I read a binary data file properly?

1102


Can you assign a different address to an array tag?

1126