WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE .
Example:
Enter the numbers :3
*
* *
* *
* *
*

Answers were Sorted based on User's Feedback



WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE . Example: Enter the numbers :3 ..

Answer / 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+(n-1);i++)
{
for(j=1;j<=n+(n-1);j++)
{
if(i+j==(n+1) || i+j==(n+n+n-1) || i-j==(n-
1) || i-j==-(n-1))
printf("*");
else
printf(" ");
}
printf("\n");
}
getch();
}

Is This Answer Correct ?    14 Yes 3 No

WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE . Example: Enter the numbers :3 ..

Answer / 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

WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE . Example: Enter the numbers :3 ..

Answer / 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

More C Interview Questions

How does C++ help with the tradeoff of safety vs. usability?

1 Answers  


Explain what is the difference between #include and #include 'file' ?

0 Answers  


What are the features of the c language?

0 Answers  


Find the highest of three numbers and print them using ascending orders?

1 Answers  


Hi, main() { } Is a user defined function or Built in Functionn

26 Answers   Honeywell, Yahoo,


When is the “void” keyword used in a function?

1 Answers  


Explain what is the difference between a string and an array?

0 Answers  


What is #line?

0 Answers  


What do you mean by c what are the main characteristics of c language?

0 Answers  


Without Computer networks, Computers will be half the use. Comment.

0 Answers  


how to get the starting address of file stored in harddisk through 'C'program.

2 Answers   Siemens,


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

0 Answers  


Categories