0% found this document useful (0 votes)
16 views1 page

#Include #Include #Include #Include

The document is a C program that prints a diamond shape pattern of stars. It prompts the user to enter the maximum number of stars, then uses nested for loops to print spaces and stars in the pattern of a diamond for both the top and bottom half of the shape, with the number of stars decreasing or increasing on each line.

Uploaded by

leloch83
Copyright
© Attribution Non-Commercial (BY-NC)
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)
16 views1 page

#Include #Include #Include #Include

The document is a C program that prints a diamond shape pattern of stars. It prompts the user to enter the maximum number of stars, then uses nested for loops to print spaces and stars in the pattern of a diamond for both the top and bottom half of the shape, with the number of stars decreasing or increasing on each line.

Uploaded by

leloch83
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 1

#include #include #include #include

<stdio.h> <conio.h> <process.h> <string.h>

void main() { int i, j, k; int n = 0; printf("Program for displaying pattern of *.\n"); printf("Enter the maximum number of *: "); scanf("%d", &n); printf("\nHere is the Diamond of Stars\n"); for (i = 1; i <= n; i++) { for (j = 0; j < (n - i); j++) printf(" "); for (j = 1; j <= i; j++) printf("*"); for (k = 1; k < i; k++) printf("*"); printf("\n"); } for (i = n - 1; i >= 1; i--) { for (j = 0; j < (n - i); j++) printf(" "); for (j = 1; j <= i; j++) printf("*"); for (k = 1; k < i; k++) printf("*"); printf("\n"); } printf("\n"); }

You might also like