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
plz let me know how to become a telecom protocol tester. thank you.
What is the heap in c?
what are enumerations in C
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is the function of this pointer?
What does #pragma once mean?
What is the difference between if else and switchstatement
main() { printf("hello"); fork(); }
Explain null pointer.
How is a pointer variable declared?
What is the use of parallelize in spark?
How can I avoid the abort, retry, fail messages?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
what is stack , heap ,code segment,and data segment
What are variables and it what way is it different from constants?