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

Answers were Sorted based on User's Feedback



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

Answer / akhil

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,n;
cout<<"enter limit";
cin>>n;
for(i=1;i<=n;i++)
//cout<<"/n"; for printing line by line
for(j=1;j<=i;j++)
cout<<j;//
getch();
}

Is This Answer Correct ?    18 Yes 1 No

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

Answer / ramesh.bugatha78

for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
cout<<j;
cout<<"\n";
}

Is This Answer Correct ?    8 Yes 0 No

Post New Answer

More C++ General Interview Questions

Explain the properties and principles of oop.

0 Answers  


When should overload new operator on a global basis or a class basis?

0 Answers  


What is the difference between C and CPP?

0 Answers   iNautix,


Why are pointers used?

0 Answers  


Under what conditions is multiple inheritance not recommended?

1 Answers  






What is enum c++?

0 Answers  


When is dynamic checking necessary?

0 Answers  


What is the precedence when there is a global variable and a local variable in the program with the same name?

0 Answers  


What will happen if a pointer is deleted twice?

0 Answers   Agilent, HAL,


What is static function? Explain with an example

0 Answers  


How do you link a C++ program to C functions?

4 Answers  


Can user-defined object be declared as static data member of another class?

0 Answers  


Categories