write the code that display the format just like
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1

Answers were Sorted based on User's Feedback



write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 ..

Answer / prasenjit roy

int main()
{
int i;
int j;
for(i = 1; i <= 6; i++)
{
for(j = i; j >= 1; j--)
cout<<j<<" ";
cout<<endl;
}
return 0;
}

Is This Answer Correct ?    4 Yes 0 No

write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 ..

Answer / bhushan

#include<iostream.h>
void main()
{
for(int i=1;i<=6;i++)
{
for(int j=i;j>=1;j--)
{
cout<<j<<"\t";
}
cout<<"\n";
}
}

Is This Answer Correct ?    1 Yes 0 No

write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 ..

Answer / gayatri chhotray

int main()
{
int i;
int j;
for(i = 1; i <= 6; i++)
{
for(j = i; j >= 1; j--)
{

cout<<j<<" ";
}
}
return 0;
}

Is This Answer Correct ?    4 Yes 4 No

write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 ..

Answer / suman_kotte

main()
{
int i,j;
for(i=1;i<=6;i++)
{
for(j=i;j>=1;j--)
printf("%d",j);
printf("\n");
}
}

Is This Answer Correct ?    1 Yes 1 No

write the code that display the format just like 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 ..

Answer / kamal

int main()
{
cout<<"1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n6 5 4 3 2 1";
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Why is c++ difficult?

0 Answers  


What is iostream in c++ used for?

0 Answers  


You have to take 2 arrays of length 10. Input the values of array 1 from the user. Then copy the values of array 1 to array 2 in ascending order For example if user enters 9, 5, 6, 8, 1, 0, 2, 7, 4, 3 then copy the smallest element i.e. 0 first followed by 1, 2 and so

1 Answers  


Can turbo c++ run c program?

0 Answers  


Write a C++ program which will compute the volume of a sphere or a cylinder after prompting the user to type the first character for the shape name.

0 Answers   An-Najah National University,






How delete [] is different from delete?

0 Answers  


What is the use of object in c++?

0 Answers  


What is pointer to array in c++?

0 Answers  


State the difference between pre and post increment/decrement operations.

0 Answers  


Can we sort map in c++?

0 Answers  


Is c++ fully object oriented?

0 Answers  


What is c++ 11 and c++ 14?

0 Answers  


Categories