C Program to draw Interesting Pattern III
Description
Input:
5
Output:
* *
** **
*** ***
**** ****
*********
Solution
#include<stdio.h>
int main()
{
int i,j,k,n;
printf("enter row size:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=1;k<=2*(n-i)-1;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
if(j!=n)
printf("*");
}
printf("\n");
}
return 0;
}
Explanation
Refer Video Tutorial
Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
*
***
*****
*******
*********
*******
*****
***
*Solution
Input:
5
Output:
* *
** **
*** ***
**** ****
**********Solution
Input:
5
Output:
* *
** **
*** ***
**** ****
*********Solution
Input:
5
Output:
* *
** **
*** ***
**** ****
*********
**** ****
*** ***
** **
* *Solution
Input:
5
Output:
*********
*******
*****
***
*
***
*****
*******
*********Solution