Write a program to give following output.....
*********
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
*********
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,k;
printf("enter the no. of lines :");
scanf("%d",&n);
for(i=1;i<=(n*2-1);i++)
{
if(!(i^1)|| !(i^(n*2-1)))
{
for(j=1;j<=(n*2-1);j++)
printf("*");
}
else
{
if(i<=n)
{
for(j=1;j<=n-i;j++)
printf("*");
for(k=1;k<(2*i);k++)
printf(" ");
for(j=n-i;j>=0;j--)
printf("*");
}
else
{
for(j=1;j<=(i-n+1);j++)
printf("*");
for(j=k-3;k<=(2*n-1);k++)
printf(" ");
for(j=i-n+1;j>0;j--)
printf("*");
}
}
getch();
}
i think this may work
thank u
Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
What is the benefit of using #define to declare a constant?
Write a program to print “hello world” without using semicolon?
Why dont c comments nest?
Is fortran still used today?
What are terms in math?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
When should a type cast not be used?
How do I copy files?
What is exit() function?
What's the total generic pointer type?
What is meant by keywords in c?
Why c is known as a mother language?
What is strcpy() function?
Compare array data type to pointer data type
What are the salient features of c languages?