Write a program in c using only loops to print *
* *
* *
*******
Answer Posted / evr
This is the generic code for printing above such pattern. You can print the above pattern for different number of rows by entering different value during run time
#include<stdio.h>
int main()
{
int n, i, j;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
if(i!= n-1)
{
for(j=1;j<=2*n;j++)
{
if(j==n-i || j==n+i)
printf("*");
else
printf(" ");
}
printf("\n");
}
else
for(i=0;i<2*n-1;i++)
printf("*");
return 0;
}
Thank you......
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How a string is stored in c?
When should you use a type cast?
Differentiate between the = symbol and == symbol?
What is the difference between variable declaration and variable definition in c?
How can you be sure that a program follows the ANSI C standard?
How can I implement sets or arrays of bits?
How can I manipulate strings of multibyte characters?
Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What do mean by network ?
Where static variables are stored in memory in c?
What is #include conio h?
What is integer constants?
Explain how to reverse singly link list.
What is binary tree in c?