Monday, May 24, 2010

Write a c++ program that prompt the user to enter a number and then display a series of numbers as follows:?

for instance, if the user enters number 4 ..the program should display:





1


22


333


4444





* I did solve this Q:





#include%26lt;iostream.h%26gt;


void main() {


int n;


cin%26gt;%26gt;n;


for(int i=1;i%26lt;=n;i++)


{


for(int j=0;i+j%26lt;=n;j++)


cout%26lt;%26lt;i;


cout%26lt;%26lt;"\n";


}


}


}





But when i run it on the compiler ... it gave this output





1111


222


33


4





Can someone help plz..

Write a c++ program that prompt the user to enter a number and then display a series of numbers as follows:?
Change


for(int j=0;i+j%26lt;=n;j++)


to


for(int j=1;j%26lt;=i;j++)
Reply:#include %26lt;stdio.h%26gt;


#include %26lt;conio.h%26gt;


void main()


{


int i,j,k,x;


clrscr();


printf(" Enter A Num : ");


scanf("%d",%26amp;x);


k=1;


for(i=1;i%26lt;=x;i++)


{


for(j=1;j%26lt;=i;j++)


printf("%d",k);


printf("\n");


k++;


}


getch();


} Report It

Reply:#include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int n;


cout%26lt;%26lt;"enter the number\n";


cin%26gt;%26gt;n;


for(int i=1;i%26lt;=n;i++)


{


for(int j=1;j%26lt;=i;j++)


cout%26lt;%26lt;i;


cout%26lt;%26lt;"\n";


}


getch();


}
Reply:... wtf is that?

hawthorn

No comments:

Post a Comment