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

Write a program to reverse a string.

0 Answers   Global Logic, iNautix, TCS, Wipro,


write a program to convert a expression in polish notation (postfix) to inline (normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix

0 Answers  


How to run c Program without using IDE of c. means if program made in notepad.then how to compile by command prompt.

1 Answers   HP, TCS,


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

0 Answers  


what is difference between array,strutter,union and pointers

3 Answers   CTS, Lovely Professional University, Mannar Company,


When was c language developed?

0 Answers  


What are structures and unions? State differencves between them.

0 Answers   iNautix,


How can variables be characterized?

0 Answers  


You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;i<n1-1;i++) { if( !( (a1[i]>a1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

0 Answers   Facebook,


Prove or disprove P!=NP.

5 Answers   Microsoft,


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

0 Answers   Wilco,


Are the expressions * ptr ++ and ++ * ptr same?

0 Answers  


Categories