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

What are the types of functions in c?

950


What is a 'null pointer assignment' error?

1182


What is the acronym for ansi?

1012


Explain what is a const pointer?

1052


What are identifiers in c?

1163


in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures

1180


Explain why C language is procedural?

1171


How the c program is executed?

1100


If null and 0 are equivalent as null pointer constants, which should I use?

1147


What is #include conio h?

966


How can I determine whether a machines byte order is big-endian or little-endian?

1022


What is scope and lifetime of a variable in c?

1008


What is an arrays?

1042


What is the use of header?

1068


What does 4d mean in c?

1460