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
Why & is used in scanf in c?
What is structure packing in c?
What does return 1 means in c?
what are bit fields in c?
Why does notstrcat(string, "!");Work?
Write a program for Overriding.
How many types of operators are there in c?
Write a program to swap two numbers without using third variable?
How to write a multi-statement macro?
Explain what is meant by 'bit masking'?
What is selection sort in c?
Can you write the algorithm for Queue?
What is LINKED LIST? How can you access the last element in a linked list?
Why do we need arrays in c?
Why enum is used in c?