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

#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

1129


What is a #include preprocessor?

1076


What is the heap?

1155


console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

1096


If fflush wont work, what can I use to flush input?

1051


What is a volatile keyword in c?

1112


What is the importance of c in your views?

1094


What is nested structure?

997


Why isn't it being handled properly?

1001


What is hashing in c language?

1188


Explain can you assign a different address to an array tag?

1014


Can we access the array using a pointer in c language?

995


When c language was developed?

1011


What are variables c?

998


How do I create a directory? How do I remove a directory (and its contents)?

1098