Showing posts with label Patterns. Show all posts
Showing posts with label Patterns. Show all posts

C program to print the pattern

 C program to print the pattern

C program to print the pattern

In this program, I have discussed about the C program to print the pattern shown above.


#include<stdio.h>
int main()
{ int i,j,k,l,m,p=1,q=3,z;
for(i=4;i>=1;i--)
{ for(j=1;j<i;j++)
{ printf(" ");
}
for(k=p;k>=1;k--)
{ printf("%d",k);
}
p++;
printf("\n");
}
for(l=1;l<=3;l++)
{ for(z=1;z<=l;z++)
{printf(" ");
}
for(m=q;m>=1;m--)
{ printf("%d",m);
}
q--;
printf("\n");
}

}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C program to print the pattern.

C program to print the pattern

C program to print the pattern.

 In this program, I have discussed about the C program to print the pattern shown above.


#include<stdio.h>
int main()
{ int i,j,k,p=1,l,q=2,r=1,c=0,m=1,z=1,y=1;
for(i=1;i<=5;i++)
{
for(j=5;j>i;j--)
{ printf("  ");
}
k=z;
while(k<=y)
{printf("%d ",k);
k++;
}
y+=2,z++;
if(c!=0)
{
l=q,p=r;
while(l>p)
{printf("%d ",l);
l--;}
q+=2,r++;
}
c++;
printf("\n");
}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.



C program to print the pattern


C program to print the pattern

C program to print the pattern

 In this program, I have discussed about the c program to print the pattern

#include<stdio.h>
int main()
{
int i,j,k,l,m;char a;
for(i=1;i<=7;i++)
{a='A';
for(j=0;j<=7-i;j++,a++)
printf("%c ",a);
for(k=2;k<(2*i)-1;k++)
printf("  ");
if(i==1)
{
a=a-2;
for(l=1;l<=7-i;l++,a--)
printf("%c ",a);
}
else
{a=a-1;
for(m=0;m<=7-i;m++,a--)
printf("%c ",a);
}
printf("\n");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C Program to print Floyd's triangle


C Program to print Floyd's triangle

https://en.wikipedia.org/wiki/C_(programming_language)


 In this program, I have discussed about C Program to print Floyd's triangle.

The pattern is shown below---
1
2 3
4 5 6
7 8 9 10


#include<stdio.h>
void main()
{int i,j,c=1,n;
printf("Enter the value of n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{for(j=1;j<=i;j++)
{printf("%d ",c);
c++;}
printf("\n");
}

}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


 

Copyright 2020 Programming in C All Right Reserved