write a c++ program that gives output
4
3 4
2 3 4
1 2 3 4 using looping statement

Answers were Sorted based on User's Feedback



write a c++ program that gives output 4 3 4 2 3 4 1 2 3 4 using looping statement..

Answer / rajesh

4
3 4
2 3 4
1 2 3 4

#include<stdio.h>

int main()
{
int i, j, n=4;

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

Is This Answer Correct ?    32 Yes 1 No

write a c++ program that gives output 4 3 4 2 3 4 1 2 3 4 using looping statement..

Answer / rajesh

This answer is to print :
4342341234

#include<stdio.h>

int main()
{
int i, space, num, n=4;

for(i=1; i<=n; i++)
{
for(space=1; space<=n-i; space++)
{
}
for(num=space; num<=n; num++)
{
printf("%d",num);
}
}
printf("\n");
}

Is This Answer Correct ?    13 Yes 3 No

write a c++ program that gives output 4 3 4 2 3 4 1 2 3 4 using looping statement..

Answer / sandeep mannnarakkal

void printSeries(int nNum)
{
for ( int i = 0 ; i < nNum ; i ++)
{
for ( int j = nNum -i ; j <= nNum ; j ++)
{
cout << j;
}
cout << endl;
}
}

Is This Answer Correct ?    0 Yes 0 No

write a c++ program that gives output 4 3 4 2 3 4 1 2 3 4 using looping statement..

Answer / rajesh

This answer is to print :
4
34
234
1234

#include<stdio.h>

int main()
{
int i, space, num, n=4;

for(i=1; i<=n; i++)
{
for(space=1; space<=n-i; space++)
{
printf(" ");
}
for(num=space; num<=n; num++)
{
printf("%d",num);
}
printf("\n");
}
printf("\n");
}

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More C++ General Interview Questions

Are vectors faster than arrays?

0 Answers  


What are keywords in c++?

0 Answers  


What is a virtual destructor? Explain the use of it?

0 Answers  


How many ways can a variable be initialized into in C++?

0 Answers   HCL,


what are the iterator and generic algorithms.

0 Answers  






what is difference between internet and Internet?

12 Answers   College School Exams Tests, Microsoft, MIT, TCS,


What is a static member?

0 Answers  


How can virtual functions in c++ be implemented?

0 Answers  


Why is null pointer used?

0 Answers  


What is scope of a variable? (LOLZ)

2 Answers   CA, TCS,


Why is main an int?

0 Answers  


What is ios flag in c++?

0 Answers  


Categories