Example 1: Program To Print Half Pyramid Using : Source Code
Example 1: Program To Print Half Pyramid Using : Source Code
Example 1: Program To Print Half Pyramid Using : Source Code
* *
* * *
* * * *
* * * * *
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
B B
C C C
D D D D
E E E E E
Source Code
#include <stdio.h>
int main()
{
int i, j;
char input, alphabet = 'A';
* * * *
* * *
* *
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
return 0;
}
1 2 3 4
1 2 3
1 2
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
return 0;
}
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Source Code
#include <stdio.h>
int main()
{
int i, space, rows, k=0;
while(k != 2*i-1)
{
printf("* ");
++k;
}
printf("\n");
}
return 0;
}
Example 7: Program to print pyramid using
numbers
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
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;
}
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
Source Code
#include<stdio.h>
int main()
{
int rows, i, j, space;
printf("\n");
}
return 0;
}
Example 9: Print Pascal's triangle
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;
}
2 3
4 5 6
7 8 9 10
Source Code
#include <stdio.h>
int main()
{
int rows, i, j, number= 1;
printf("\n");
}
return 0;
}