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 9 No

Post New Answer

More C++ General Interview Questions

Give 10 points of differences between C & C++.

0 Answers   HCL,


What operators can you overload in c++?

0 Answers  


What is c++ library?

0 Answers  


What are advantages of C++ when comparing with C?

18 Answers   HP, iGate, TCS,


Is c++ primer good for beginners?

0 Answers  


How can you tell what shell you are running on unix system?

0 Answers  


If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3

0 Answers  


What about Virtual Destructor?

1 Answers   Virtusa,


Write any small program that will compile in "C" but not in "C++"

10 Answers   Honeywell,


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

0 Answers   Yahoo,


what is Loop function? What are different types of Loops?

0 Answers  


What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?

3 Answers  


Categories