To Print Output like
*
**
***
****
*****
******
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
printf("\n");
for(j=1;j<=i;j++)
printf("*");
}
getch();
}
TO reverse the output
*****
****
***
**
*
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=5;i--)
{
printf("\n");
for(j=1;j<=i;j++)
printf("*");
}
getch();
}
We can play with the code to get some more output
1
12
123
1234
12345
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
printf("\n");
for(j=1;j<=i;j++)
printf("%d",j);
}
getch();
}
To reverse the output
12345
1234
123
12
1
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
printf("\n");
for(j=1;j<=i;j++)
printf("%d",j);
}
getch();
}
Categories:
c program
,
Special Codes
,
Star Codes
0 comments:
Post a Comment