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
What is the code in while loop that returns the output of given code?
What is a newline escape sequence?
In C programming, what command or code can be used to determine if a number of odd or even?
Between macros and functions,which is better to use and why?
What is a structure in c language. how to initialise a structure in c?
What is NULL pointer?
Why flag is used in c?
What type is sizeof?
What is the difference between call by value and call by reference in c?
How can I send mail from within a c program?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
write a program to generate address labels using structures?
What is null in c?
In which layer of the network datastructure format change is done
Explain what is the difference between functions abs() and fabs()?