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;
1
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;
A
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';
printf("\n");
}
return 0;
}
* * * * *
* * * *
* * *
* *
*
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
return 0;
}
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Source Code
#include <stdio.h>
int main()
{
int i, j, rows;
printf("Enter number of rows: ");
scanf("%d",&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;
}
1
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;
}
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;
}
1
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;
}
#include <stdio.h>
int hcf(int n1, int n2);
int main()
{
int n1, n2;
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);
Output
while(n != 0)
{
// n = n/10
n /= 10;
++count;
}
Number of digits: 4