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
Explain the ternary tree?
What is #include stdlib h?
Can the curly brackets { } be used to enclose a single line of code?
What is the use of structure padding in c?
What is the use of in c?
Explain the concept and use of type void.
Are there constructors in c?
What is the mean of function?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
Why is structure padding done in c?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
i got 75% in all semester am i eligible for your company
What does c mean before a date?
write a c program to find the sum of five entered numbers using an array named number
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above