Write a program in c using only loops to print *
* *
* *
*******
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / veera
#include<stdio.h>
#include<math.h>
main()
{
clrscr();
printf("*");
printf("\n");
printf("* *");
printf("\n");
printf("* *");
printf("\n");
printf("*******");
getch();
}
| Is This Answer Correct ? | 2 Yes | 4 No |
How can I dynamically allocate arrays?
what is differnence b/w macro & functions
wat s the meaning of (int *)p +4;
Explain how can I convert a string to a number?
main() { int i=400,j=300; printf("%d..%d"); }
how to find sum of 5 digits in C?
Why header file is used in c?
How to add two numbers without using semicolon at runtime
How do you determine whether to use a stream function or a low-level function?
what are the files which are automatically opened when a c file is executed?
write a c program to print "Welcome" without using semicolon in the whole program ??
What are the disadvantages of c language?