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".
No comments:
Post a Comment