Custom Search

Monday, 21 November 2011

C/C++ Program to print star pattern, Program to print star pattern in pyramid form, Program to print star pattern in decreasing form.


C/C++ Program to print star pattern, Program to print star pattern in pyramid form, Program to print star pattern in decreasing form.

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("*");
}}
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