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
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
what are the different storage classes in c?
What does c mean in standard form?
Tell us bitwise shift operators?
What is the difference between array and pointer?
What are variables and it what way is it different from constants?
How reliable are floating-point comparisons?
How many types of functions are there in c?
What are the Advantages of using macro
Explain what is the benefit of using an enum rather than a #define constant?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
What is a substring in c?
How many data structures are there in c?
What are qualifiers in c?
What is difference between structure and union with example?