0% found this document useful (0 votes)
11 views6 pages

Assignment#03: Name:Usama Roll No#21

The document contains six C programming assignments that demonstrate various patterns using asterisks. Each program includes a nested loop structure to create different shapes, such as right-aligned triangles and inverted pyramids. The output for each program is also indicated, showcasing the visual result of the code.

Uploaded by

q809401
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Assignment#03: Name:Usama Roll No#21

The document contains six C programming assignments that demonstrate various patterns using asterisks. Each program includes a nested loop structure to create different shapes, such as right-aligned triangles and inverted pyramids. The output for each program is also indicated, showcasing the visual result of the code.

Uploaded by

q809401
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment#03

Name:UsAmA
Roll No#21

Program#01:

#include <stdio.h>
int main()
{
int i, j;
for(i = 1; i <= 5; i++)
{

for(j = 1; j <= 5 - i; j++)


{
printf(" ");
}
for(j = 1; j <= i; j++)
{
printf("*");
}
printf("\n");
}
getchar();
return 0;
}

Output:
Program #02:

#include<stdio.h>
int main ()
{
int i,j;
for(i=0; i<5; i++)
{
for(j=0; j<=i; j++)
printf("*");
printf("\n");
}
getchar();
return 0;
}

Output:
Program#03:

#include <stdio.h>
int main()
{
int i,j, spaces, stars;
for(i = 1; i <= 5; i++)
{
for(spaces = 1; spaces <= 5 - i; spaces++)
{
printf(" ");
}
for(stars = 1; stars <= (2 * i - 1); stars++)
{
printf("*");
}
printf("\n");
}
getchar();
return 0;
}

Output:
Program #04:

#include <stdio.h>
int main()
{
int i, j;
for(i = 0; i < 5; i++)
{
for(j = 0; j < i; j++)
{
printf(" ");
}
for(j = 5 - i; j > 0; j--)
{
printf("*");
}
printf("\n");
}
getchar ();
return 0;
}

Output:
Program #05:

#include <stdio.h>
int main()
{
int i, j;
for(i = 5; i >= 1; i--)
{

for(j = 1; j <= i; j++)


{
printf("*");
}
printf("\n");
}
getchar ();
return 0;
}
Output:
Program #06:

#include <stdio.h>

int main()
{
int i, j;

for(i = 0; i < 5; i++)


{
for(j = 0; j < i; j++)
{
printf(" ");
}
for(j = 0; j < (9 - 2*i); j++)
{
printf("*");
}
printf("\n");
}
getchar ();
return 0;
}
Output:

You might also like