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
What is formal argument?
What is main return c?
What is the purpose of & in scanf?
What are the disadvantages of external storage class?
Can include files be nested?
Why c is a mother language?
how to create duplicate link list using C???
What is scope rule in c?
What is main function in c?
What is the purpose of 'register' keyword?
How can I trap or ignore keyboard interrupts like control-c?
Explain what is a stream?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
What does nil mean in c?
What is use of #include in c?