WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE .
Example:
Enter the numbers :3
*
* *
* *
* *
*
Answer Posted / shakil ahmed
#include<stdio.h>
#include<conio.h>
main()
{
int i, j,s,si,n;
scanf("%d",&n);
s=n-1;
si=1;
for(i=1; i<=n-1; i++)
printf(" ");
printf("*\n");
for(i=1; i<=n-1; i++)
{
for(j=1; j<=s-1; j++)
printf(" ");
s--;
printf("*");
for(j=1; j<=si; j++)
printf(" ");
si+=2;
printf("*\n");
}
s=1;
si-=4;
for(i=1; i<=n-2; i++)
{
for(j=1; j<=s; j++)
printf(" ");
s++;
printf("*");
for(j=1;j<=si;j++)
printf(" ");
si-=2;
printf("*\n");
}
for(i=1; i<=n-1; i++)
printf(" ");
printf("*\n");
}
| Is This Answer Correct ? | 9 Yes | 10 No |
Post New Answer View All Answers
Does c have circular shift operators?
What are register variables in c?
What is the purpose of the statement: strcat (S2, S1)?
What is default value of global variable in c?
What is difference between structure and union in c programming?
What are examples of structures?
Explain how do you override a defined macro?
Can you mix old-style and new-style function syntax?
What is huge pointer in c?
What are the modifiers available in c programming language?
What are the different types of control structures?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What is null in c?
What language is windows 1.0 written?
What is pass by reference in c?