Custom Search

Saturday 16 April 2011

C/ C++ Program to print numbers in increasing order in pyramid form, C program to print 122333444455555.


C/ C++ Program to print numbers in increasing order in pyramid form, C program to print 122333444455555.



Program

#include<stdio.h>
#include<conio.h>
void main()
{ int i,j;
clrscr();
for(i=1;i<6;i++)
{ printf("\n");
for(j=1;j<=i;j++)
{ printf("%d",j);
}}
getch();
}

Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h" 
2.)  for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.


Click here to check the output

No comments:

Post a Comment

Laptops