WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE .
Example:
Enter the numbers :3
*
* *
* *
* *
*
Answer Posted / sagarsp2010
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("\nEnter the No. :");
scanf("%d",&n);
for(i=1;i<=n-1;i++)
{
for(j=n-1;j>=i;j--)
{
if(i==j)
printf(" *");
else
printf(" ");
}
for(j=1;j<=n;j++)
{
if(i==j && i!=1 && i!=(n-(n-1)))
printf("*");
else if(j==2 || i==2)
printf(" ");
else
printf(" ");
}
printf("\n");
}
for(i=1;i<=n+1;i++)
{
for(j=1;j<=n;j++)
{
if(i==j)
printf("*");
else
printf(" ");
}
for(j=n-1;j>=i;j--)
{
if(i==j)
printf("*");
else
printf(" ");
}
printf("\n");
}
getch();
}
Is This Answer Correct ? | 8 Yes | 5 No |
Post New Answer View All Answers
Can two or more operators such as and be combined in a single line of program code?
What does struct node * mean?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
Which is the best website to learn c programming?
What is an identifier?
Differentiate call by value and call by reference?
What is "Duff's Device"?
FILE PROGRAMMING
How can you determine the maximum value that a numeric variable can hold?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Explain what is the benefit of using const for declaring constants?
What is a pointer and how it is initialized?
What is pointers in c with example?
largest Of three Number using without if condition?
What is the most efficient way to store flag values?