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
Difference between strcpy() and memcpy() function?
Which node is more powerful and can handle local information processing or graphics processing?
What is a pointer variable in c language?
Explain what is wrong with this statement? Myname = ?robin?;
Differentiate call by value and call by reference?
What is variable and explain rules to declare variable in c?
Why is event driven programming or procedural programming, better within specific scenario?
Is it cc or c in a letter?
how should functions be apportioned among source files?
What is the acronym for ansi?
Why can't I perform arithmetic on a void* pointer?
Can I initialize unions?
What is wrong with this declaration?
Explain what are reserved words?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above