Problem 1_________________________
*******
*******
*******
*******
*******
*******
*******
Source
Code:-
#include<stdio.h>
void main()
{
int r,c;
for (r=1;r<=7;r++)
{
for (c=1;c<=7;c++)
printf("*");
printf("\n");
}
}
Problem 2_________________________
*
**
***
****
*****
******
*******
Source
Code:-
#include<stdio.h>
void main()
{
int r,c;
for (r=1;r<=7;r++)
{
for (c=1;c<=r;c++)
printf("*");
printf("\n");
}
}
Problem 3_________________________
*******
******
*****
****
***
**
*
Source
Code:-
#include<stdio.h>
void main()
{
int r,c;
for (r=1;r<=8;r++)
{
for (c=9;c>r;c--)
{
printf("*");
}
printf("\n");
}
}
Problem 4_________________________
********
* *
* *
* *
* *
* *
* *
********
Source
Code:-
#include<stdio.h>
void main()
{
int r,c;
for (r=1;r<=8;r++)
{
for (c=1;c<=8;c++)
{
if (r==8 || r==1)
printf("*");
else if (c==1 ||
c==8)
(printf("*"));
else
(printf(" "));
}
printf("\n");
}
}
Problem 5_________________________
********
********
********
********
********
********
********
********
Source
Code:-
#include<stdio.h>
void main()
{
int r,c,n,d;
for (r=1;r<=8;r++)
{
for(c=1;c<=9;c++)
{
n=r%2;
d=c%2;
if (c==9 && n!=0)
printf(" ");
else if (c==1
&& n==0)
printf(" ");
else
printf("*");
}
printf("\n");
}
}
Problem 6_________________________
*
**
***
****
*****
******
*******
*********
Source
Code:-
#include<stdio.h>
void main()
{
int r,c;
for (r=1;r<=5;r++)
{
for (c=1;c<=(r+4);c++)
{
if(c<=(5-r))
printf(" ");
else
printf("*");
}
printf("\n");
}
}
0 comments:
Post a Comment