To print the star pattern
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,sp,n;
clrscr();
printf("enter the number");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(sp=n-1;sp>i;sp--)
{
printf(" ");
}
for(j=0;j<=2*i;j++)
{printf("*");
}
printf("\n");
}
getch();
}
/*
output
---------------
enter the number5
*
***
*****
*******
*********
*/
#include<conio.h>
void main()
{
int i,j,sp,n;
clrscr();
printf("enter the number");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(sp=n-1;sp>i;sp--)
{
printf(" ");
}
for(j=0;j<=2*i;j++)
{printf("*");
}
printf("\n");
}
getch();
}
/*
output
---------------
enter the number5
*
***
*****
*******
*********
*/
This code is wrong for that desired output!!!!!!!!!
ReplyDelete