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
How to write a code for implementing my own printf() and
scanf().... Please hep me in this... I need a guidance...
Can you give an coding for c... Please also explain about
the header files used other than #include
When should you not use a type cast?
Why ca not I do something like this?
what is a constant pointer in C
Why main function is special give two reasons?
What is an auto keyword in c?
What is assignment operator?
Why C language is a procedural language?
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
Explain what is the concatenation operator?
What is difference between && and & in c?
What does emoji p mean?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
How can you increase the size of a statically allocated array?
Explain how do you override a defined macro?