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


Please Help Members By Posting Answers For Below Questions

Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

617


what are the different storage classes in c?

667


What does c mean in standard form?

604


Tell us bitwise shift operators?

603


What is the difference between array and pointer?

571






What are variables and it what way is it different from constants?

794


How reliable are floating-point comparisons?

632


How many types of functions are there in c?

587


What are the Advantages of using macro

689


Explain what is the benefit of using an enum rather than a #define constant?

728


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

1701


What is a substring in c?

591


How many data structures are there in c?

620


What are qualifiers in c?

576


What is difference between structure and union with example?

603