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

Explain how does flowchart help in writing a program?

1113


What is c programming structure?

1185


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

3173


What does char * * argv mean in c?

1053


What are the similarities between c and c++?

1064


What are reserved words with a programming language?

1131


What is const volatile variable in c?

1031


How many levels of pointers can you have?

1188


How can I find out how much free space is available on disk?

1050


Can you assign a different address to an array tag?

1162


What is mean by data types in c?

1027


What is the value of uninitialized variable in c?

1029


What is the use of pragma in embedded c?

1050


What is difference between arrays and pointers?

1063


What are linker error?

1088