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 what does the characters 'r' and 'w' mean when writing programs that will make use of files?
Is there a way to jump out of a function or functions?
What is unsigned int in c?
What is the difference between constant pointer and constant variable?
What is double pointer in c?
Why do some versions of toupper act strangely if given an upper-case letter?
Are global variables static in c?
Explain how does free() know explain how much memory to release?
What is strcpy() function?
What is the argument of a function in c?
What is build process in c?
Differentiate between full, complete & perfect binary trees.
Why do we need functions in c?
How does sizeof know array size?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?