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
about c language
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
while initialization of array why we use a[][2] why not a[2][]...?
What is scope rule in c?
What is nested structure in c?
what do you mean by inline function in C?
What does dm mean sexually?
What is the use of ?
What does 3 periods mean in texting?
What is volatile c?
Explain what is wrong in this statement?
How do I get a null pointer in my programs?
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?
What is the purpose of the statement: strcat (S2, S1)?
Explain what is output redirection?