C Program to print the series of star pattern .

  Hello Everyone,

So in this blog we are going to solve  various questions of star series in c language . So it is very interesting and exciting project. 


So let's get started .


Question 1 : 

  Write a Program to print the following series .

*

**

***

****

*****


solution :

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("enter the number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

Output : 


Question 2 : 

  Write a Program to print the following series .

                   *

               ***

            *****

         *******

Solution : 

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,r;
clrscr();
printf("enter the number : ");
scanf("%d",&r);
for(x=1;x<=r;++x)
{
for(y=x;y<r;++y)
{
printf(" ");
}
for(y=1;y<=x;++y)
{
printf("*");
}
printf("\n");
}
getch();
}

Output : 


Question 3 : 

  Write a Program to print the following series .

                *

              ***

            *****

          *******

Solution : 

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,r;
clrscr();
printf("enter the number : ");
scanf("%d",&r);
for(x=1;x<=r;x++)
{
for(y=x;y<r;y++)
{
printf(" ");
}
for(y=1;y<=(2*x-1);y++)
{
printf("*");
}
printf("\n");
}
getch();
}

Output  : 



Question  4 : 

Write a Program to print the following series .

Solution : 

Output : 



Hope you enjoyed it  . For any querys please let me know in the comment section . Tuned it for more codes . 


Comments

Popular Posts