0% found this document useful (0 votes)
3 views7 pages

Physics

The document contains six C programming assignments that involve printing various patterns using asterisks. Each assignment includes a code snippet that demonstrates how to create different shapes, such as right-angled triangles and inverted triangles, using nested loops. The patterns are based on a fixed integer value of 5, which determines the height of the shapes.

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)
3 views7 pages

Physics

The document contains six C programming assignments that involve printing various patterns using asterisks. Each assignment includes a code snippet that demonstrates how to create different shapes, such as right-angled triangles and inverted triangles, using nested loops. The patterns are based on a fixed integer value of 5, which determines the height of the shapes.

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/ 7

Assignment No.

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

int main()
{
int n = 5;
for (int i = 1; i <= n; i++)
{

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


{
printf("*");
}
printf("\n");
}
return 0;
}

Q.3:
#include <stdio.h>
int main()
{
int n = 5;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n - i; j++)
{
printf(" ");
}

for (int j = 1; j <= (2 * i - 1); j++) {


printf("*");
}
printf("\n");
}
return 0;
}

Q.4:
#include <stdio.h>

int main()
{
int n = 5;
for (int i = 1; i <= n; i++)
{

for (int j = 5; j >= n - i; j--)


{
printf(" ");
}

for (int j = 5; j >= i; j--)


{
printf("*");
}
printf("\n");
}
return 0;
}
Q.5:
#include <stdio.h>

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

int main()
{
int n = 5;
for (int i = 1; i <= n; i++)
{

for (int j = 9; j >= n - i; j--)


{
printf(" ");
}

for (int j = 9; j >= (2 * i - 1); j--)


{
printf("*");
}
printf("\n");
}
return 0;
}

You might also like