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

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j;
clrscr();

for(i=5;i>1;i=i-2)
{
for(j=i;j>=1;j--)
printf("%d",j);

printf("\n");

for(j=1;j<i;j++)
printf("%d",j);

printf("\n");
}
printf("1");
for(i=2;i<=5;i=i+2)
{
printf("\n");

for(j=i;j>=1;j--)
printf("%d",j);

printf("\n");

for(j=1;j<=i+1;j++)
printf("%d",j);
}

getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3252


what are the advantages of a macro over a function?

1152


What is build process in c?

1164


Explain heap and queue.

1100


When is the “void” keyword used in a function?

1513


What is the difference between typedef struct and struct?

1115


How do we make a global variable accessible across files? Explain the extern keyword?

1888


What are the scope of static variables?

1198


How many levels of pointers have?

1058


What math functions are available for integers? For floating point?

1144


Should I learn data structures in c or python?

1032


What does c mean in standard form?

1188


What is the use of sizeof () in c?

1062


How many types of arrays are there in c?

1049


Is there anything like an ifdef for typedefs?

1157