Write a program in c language to draw a diamond shaped if you give the number?

1 answer

Answer

1246002

2026-04-18 01:45

+ Follow

Hey, It is not the exact logic for a given program.

Here i m giving the code with minimum number of executing steps.

also i m sure that there doesn't exist any other way to print the same Diamond such that code executing steps will be less than mine.

It is not copied from any website, book etc.

#include

void main()

{

int n,i,s,k,flagReverce=0;

printf("Enter the no. of rows\n");

scanf("%d", &n);

for (i=1; i>=1; i++)

{

for (s=n; s>i; s-)

printf(" ");

for(k=1; k<(i*2)-1; k++)

printf("*")

printf("\n")

if (i == n)

flagReverce = 1

if (flagReverce = 1)

i-=2

}

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.