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 / anand.dayalan@gmail.com

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

void main()
{
for(int i=1; i<=2; i++)
for(int j=(i==1)?1:2;j<=5;j++)
{
for(int k = (j%2==1 && i==1)? 5 + 1 -j: (j%2==0 && i==2)?
j:1; (j%2==1 && i==1)? k>=1: (j%2==0 && i==2)? k>=1:(j%2==0
&& i==1)?k<=5 + 1 -j:k<=j ;(j%2==1 && i==1)? k--: (j%2==0 &&
i==2)? k--:k++)
printf("%d", k);
printf("\n");
}
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between declaring a variable and defining a variable?

1003


What does the function toupper() do?

1079


How can I find out if there are characters available for reading?

1079


What are the advantages of using new operator as compared to the function malloc ()?

1297


What is the use of a conditional inclusion statement in C?

1026


What is sizeof array?

1016


Is fortran still used in 2018?

998


What are shell structures used for?

997


Are comments included during the compilation stage and placed in the EXE file as well?

1041


What are header files? What are their uses?

1145


write a program to generate address labels using structures?

4537


What does c mean before a date?

1129


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

2021


Is register a keyword in c?

1003


What is extern keyword in c?

1098