Search This Blog

Thursday, July 4, 2019

Write a c program to print a star pattern-13

#include<stdio.h>
int main()
{
int i,j,k=0,rows;
printf("Enter the number of rows\n");
scanf("%d",&rows);
for(i=1;i<=rows;i++)
{
i<=(rows+1)/2?k++:k--;
for(j=1;j<=(rows+1)/2;j++)
{

if(j<=k)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");

}
return 0;
}

No comments:

Post a Comment

Wap in c to print the factorial of a number

 #include<stdio.h> int main() { int i,f=1; printf("Enter a number\n"); scanf("%d",&n); for(i=0;i<n;i++) { f...