Question 1:

*
**
***
****
*****

#include<stdio.h>
void main()
{
int i,j,n;
printf(“Enter the Number of lines:”);
scanf(“%d”,&n);
for(i=n;i>=1;i–)
{
for(j=n;j>=i;j–)
printf(“*”);
printf(“\n”);
}
}

Question 2:

*****
****
***
**
*

#include<stdio.h>
void main()
{
int i,j;
for(i=5;i>=1;i–)
{
for(j=i;j>1;j–)
printf(“*”);
printf(“\n”);
}
}

Question 3:

*
*      *
*      *      *
*     *       *     *
*      *      *      *      *
#include<stdio.h>
void main()
{
int i,j;
for(i=5;i>=1;i–)
{
for(j=1;j<=i;j++)
printf(” “);
for(j=5;j>=i;j–)
printf(“* “);
printf(“\n”);
}
}

Question 4:

A
AB
ABC
ABCD
ABCDE

#include<stdio.h>
void main()
{
int i,j;
for(i=65;i<=69;i++)
{
for(j=65;j<=i;j++)
printf(“%c”,j);
printf(“\n”);
}
}

Question 5:

*
***
*****
*******
*********

#include<stdio.h>
void main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=i;j<5;j++)
printf(” “);
for(j=0;j<(2*i+1);j++)
printf(“*”);
printf(“\n”);
}
}

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s