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
Here is a good puzzle: how do you write a program which produces its own source code as output?
application attempts to perform an operation?
about c language
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
Explain what is the benefit of using an enum rather than a #define constant?
Where is c used?
Is boolean a datatype in c?
What is class and object in c?
What is the use of typedef in c?
What is a dynamic array in c?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What is the use of printf() and scanf() functions?
Tell us two differences between new () and malloc ()?
Sir i need notes for structure,functions,pointers in c language can you help me please
explain what is fifo?