#include
<stdio.h>
void main()
{
int i,j;
for (i=0; i<5; i++)
{
for (j=0; j<=i;
j++) {
printf("
* ");
}
printf("\n");
}
}
|
*
* *
* * *
* *
* *
* *
* * *
|
#include
<stdio.h>
void main()
{
int i,j,k;
for (i=1; i<=5; i++) {
for (j=5; j>=i;
j--) {
printf("
");
}
for (k=1; k<=i; k++) {
printf("*");
}
printf("\n");
}
}
|
* **
***
****
*****
|
#include
<stdio.h>
void main()
{
int i,j,k,s=1;
for (i=5; i>=1; i--) {
for (k=s; k>=0;
k--) {
printf("
");
}
for (j=i; j>=1; j--) {
printf("*");
}
s = s + 1;
printf("\n");
}
}
|
***** ****
***
**
*
|
#include
<stdio.h>
void main()
{
int i,j;
for (i=5; i>=1; i--) {
for (j=1; j<=i;
j++) {
printf("
* ");
}
printf("\n");
}
}
|
* * * * *
* * * *
* * *
* *
*
|
#include
<stdio.h>
void main()
{
int i,j,k,t=0;
for (i=1; i<=5; i++) {
for (k=0; k<5-i;
k++) {
printf(" ");
}
for (j=0; j< i; j++) {
printf("
* ");
t = t + 1;
}
printf("\n");
}
}
|
* * *
* * *
* * * *
* * * * *
|
#include
<stdio.h>
void main()
{
int i,j,k,t=0;
for (i=1; i<=5; i++) {
for (k=0; k<5-i;
k++) {
printf(" ");
}
for (j=0; j< 2*i-1;
j++) {
printf("
* ");
}
printf("\n");
}
}
|
* * * *
* * * * *
* * * * * * *
* * * * * * * * *
|
#include
<stdio.h>
void main() {
int i,j,k,s=1;
for (i=1; i<=5; i++) {
for (k=s; k<=5;
k++) {
printf("
");
}
for (j=0; j< i;
j++) {
printf("*");
}
s = s + 1;
printf("\n");
}
s = 1;
for (i=4; i>=1; i--) {
for (k=s; k>=0;
k--) {
printf("
");
}
for (j=i; j>=1;
j--) {
printf("*");
}
s = s + 1;
printf("\n");
}
}
|
*
**
***
****
*****
****
***
**
*
|
#include
<stdio.h>
void main() {
int row, c, no=1 ,len=5;
for (row=1; row<=len; row++) {
printf("\n");
for (c=1; c<=row;
c++) {
printf("
%2d ", no);
no++;
}
}
}
|
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
|
#include
<stdio.h>
void main()
{
int i, j=5, k, x;
for (i=1;i<=5;i++) {
for (k=1;k<=j;k++)
{
printf("
");
}
for (x=1;x<=i;x++) {
printf("%d",i);
printf("
");
}
printf("\n");
j=j-1;
}
}
|
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
|
Mathematics(IX, X, XI, XII) CBSE & UP Board & CSE(C programming, Python, JAVA, Data Structure, IoT, IT, CBNST etc.)
Wednesday, December 12, 2018
C program to print patterns
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment