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

When should you use multiple inheritance?

2 Answers  


What is a "RTTI"?

6 Answers   HCL,


Define a constructor?

0 Answers  


What is the use of volatile variable?

0 Answers  


What new()is different from malloc()?

0 Answers  






Write a C program to calculate the salary of each employee in your company. You need to input the hours worked and the hourly rate. The company pays 1.5 times the hourly rate for all hours worked in excess of 48 hours. Use the formulas below to calculate the salary: if employee worked less than 48 hours salary = hours * rate; if employee worked more than 48 hours salary = 48.0 * rate + ( hours &#8722; 48.0 ) * rate * 1.5; You are required to use a loop to produce the sample output as given below.

1 Answers  


Write about an iterator class?

0 Answers  


How can I learn c++ easily?

0 Answers  


Define friend function.

0 Answers  


WHAT IS THE ABREVATION OF FORTRAN?

4 Answers  


What is ios in c++?

0 Answers  


What c++ is used for?

0 Answers  


Categories