Pattern 1 (Id-3457)
sol:-C-CODE:
Given the value of ‘n’, develop an algorithm and write a C program to print the following pattern. When the value of ‘n’ is 5, the pattern will look as follows:
*****
****
***
**
*
Input Format
First line contains the value of ‘n’
Output Format
Print the pattern given in the questionsol:-C-CODE:
#include<stdio.h>
int main()
{
int n,i,j,k;
scanf("%d",&n);
for (i=1;i<=n;i++){
for (k=1;k<i;k++)
printf(" ");
for (j=n;j>=i;j--)
printf("*");
printf("\n");}
}
int main()
{
int n,i,j,k;
scanf("%d",&n);
for (i=1;i<=n;i++){
for (k=1;k<i;k++)
printf(" ");
for (j=n;j>=i;j--)
printf("*");
printf("\n");}
}
0 Comments