Example 1: Program To Print Half Pyramid Using
Example 1: Program To Print Half Pyramid Using
Example 1: Program To Print Half Pyramid Using
*
**
***
****
*****
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
printf("Enter the uppercase character you want to print in last row: ");
scanf("%c",&input);
printf("\n");
}
return 0;
}
Example 4: Inverted half pyramid using *
*****
****
***
**
*
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
return 0;
}
while(k != 2*i-1)
{
printf("* ");
++k;
}
printf("\n");
}
return 0;
}
1
232
34543
4567654
567898765
Source Code
#include <stdio.h>
int main()
{
int i, space, rows, k=0, count = 0, count1 = 0;
while(k != 2*i-1)
{
if (count <= rows-1)
{
printf("%d ", i+k);
++count;
}
else
{
++count1;
printf("%d ", (i+k-2*count1));
}
++k;
}
count1 = count = k = 0;
printf("\n");
}
return 0;
}
Example 8: Inverted full pyramid using *
*********
*******
*****
***
*
Source Code
#include<stdio.h>
int main()
{
int rows, i, j, space;
printf("\n");
}
return 0;
}
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Source Code
#include <stdio.h>
int main()
{
int rows, coef = 1, space, i, j;
printf("%4d", coef);
}
printf("\n");
}
return 0;
}
Example 10: Print Floyd's Triangle.
1
23
456
7 8 9 10
Source Code
#include <stdio.h>
int main()
{
int rows, i, j, number= 1;
printf("\n");
}
return 0;
}
*
* *
* * *
* * * *
* * * * *
#include<stdio.h>
int main()
{
printf("\n");
no_of_spaces--;
}
return 0;