Top 5 program In C language .
Top 5 program in C language |
If you know C language and want to increase your programming skills further, then this post is for you, in this post today we are going to talk about, TOP 5 Program In C Language. You all know that C is a middle level language, the coding of unix operating system is written in C langauge, and in this post you will find Top 5 program In C language. This post of today is based on pattern system, This means that in today's post, we will create some new types of patterns and will also see their coding as well.
So that you can develop your programming skills, and increase the maximum programming skills. If you have ever made a Diamond pattern program in C language, then you will definitely understand this Top 5 Program In C Language, because in this post we will see some advanced level diamond printing, Hello Friends my name is Uttam Kumar And welcome, on our blog and with a new post top 5 program in C language.
TOP 5 PROGRAM IN C LANGUAGE. -2021
It is based all 5 program on loops, and you will know how important the loop is in C language, if you learn how to run loops in C language, then you will not have any difficulty in learning any other language. In this post top 5 program in C language, we will use only For loop, and with the help of that we will create all the pattern programs, so let's start.|Also Read :- Python basics program
1. Heart Program in C language 2021.
This is the first program of our post, in which we will learn to create a heart with the help of C language, and at the same time you will get its coding, so that you can understand the code in a better way, and we hope that you will understand , first I see the output of this program, and then after that we will talk about its coding.heart program in C language 2021 |
Look at the output and think about how the program might have worked, where to print the space and where *. And to create this pattern we have used 8 loops, it is very easy to create a program, you just have to understand its logic, and with this we have declared three integer type variables, in which a variable user input number is Will take, and accordingly the size of the heart will be larger, meaning this pattern is based on the user system.
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
printf("Enter your desire value\n");
scanf("%d",&c);
for(a=c/2;a<c;a+=2)
{
for(b=1;b<(c-a);b+=2)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("*");
}
for(b=1;b<=(c-a);b++)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("*");
}
printf("\n");
}
for(a=c;a>=1;a--)
{
for(b=a;b<c;b++)
{
printf(" ");
}
for(b=1;b<=(a*2)-1;b++)
{
printf("*");
}
printf("\n");
}
getch();
}
#include<conio.h>
main()
{
int a,b,c;
printf("Enter your desire value\n");
scanf("%d",&c);
for(a=c/2;a<c;a+=2)
{
for(b=1;b<(c-a);b+=2)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("*");
}
for(b=1;b<=(c-a);b++)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("*");
}
printf("\n");
}
for(a=c;a>=1;a--)
{
for(b=a;b<c;b++)
{
printf(" ");
}
for(b=1;b<=(a*2)-1;b++)
{
printf("*");
}
printf("\n");
}
getch();
}
You can run this program by copying and pasting this code in any of your C language editors, if you get an error while running the program, then you leave a comment, and your error will be solved | So let's see another pattern program.
2. X-MAS tree In C Language 2021.
Yes friends, in this program we will see how we can make X-MAS tree, this program is some tough, but we hope that you will definitely understand, but if you have any problem then you can ask by comment , some syntax in this program we have to keep in mind, if any syntax is wrong then the pattern of X-MAS tree will not be printed. First of all, see the output of this program.X-mas tree program in c language 2021 |
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,he,wi,gap,r=1,m=1;
clrscr();
printf("Enter X-MAS tree height");
scanf("%d",&he);
printf("Enter X-MAS tree width");
scanf("%d",&wi);
gap=wi*5;
for(r=1;r<=he;r++)
{
for(a=m;a<=wi;a++)
{
for(b=gap;b>=a;b--)
{
printf(" ");
}
for(c=1;c<=a;c++)
{
printf("* ");/*give a single space after (* ) */
}
printf("\n");
}
m+=2;
wi+=2;
}
for(a=1;a<=4;a++)
{
for(b=gap-3;b>=1;b--)
{
printf(" ");
}
for(c=1;c<=4;c++)
{
printf("* "); /*give a single space after (* ) */
}
printf("\n");
}
getch();
}
#include<conio.h>
int main()
{
int a,b,c,he,wi,gap,r=1,m=1;
clrscr();
printf("Enter X-MAS tree height");
scanf("%d",&he);
printf("Enter X-MAS tree width");
scanf("%d",&wi);
gap=wi*5;
for(r=1;r<=he;r++)
{
for(a=m;a<=wi;a++)
{
for(b=gap;b>=a;b--)
{
printf(" ");
}
for(c=1;c<=a;c++)
{
printf("* ");/*give a single space after (* ) */
}
printf("\n");
}
m+=2;
wi+=2;
}
for(a=1;a<=4;a++)
{
for(b=gap-3;b>=1;b--)
{
printf(" ");
}
for(c=1;c<=4;c++)
{
printf("* "); /*give a single space after (* ) */
}
printf("\n");
}
getch();
}
Minimum Height : 5
Minimum width : 5
This program is also based on the user system, As a user does not input the number in it, the program will not run, and you should enter values from 5 to 20 in this program, because if you enter a larger value , the size of the X-mas tree will become very large and it will not show on your computer screen, so let's see the third program
3. Pyramid Pattern In C language 2021.
This pattern is asked lot in the exam, and along with it the diamond pattern is also asked, in terms of exam, these patterns are very important. So today we will learn to make pyramid pattern in C language . In this program we will only use for loop to create this program, we have used 7 variable of integer type. In which a variable will take input of data from the user. And we have used 9 for loop in this program. First of all, you see this output.pyramid pattern IN C language |
#include<stdio.h>
#include<conio.h>
main()
{
int he,gap,a,b,c,n,x=1;
clrscr();
printf("Enter the height of the pyramid\n");
scanf("%d",&he);/* give the value between 5 to 20 ,because screen not cover of pyramid size*/
gap=he-1;
for(a=1;a<=he;a++)
{
for(n=1;n<=he;n++)
{
printf(" ");
}
for(c=gap;c>=a;c--)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("* ");/* give a singal space after (*) */
}
printf("\n");
}
for(a=0;a<he;a++)
{
for(b=gap;b>a;b--)
{
printf(" ");
}
for(c=0;c<=a;c++)
{
printf("* ");/* give a singal space after (*) */
}
for(n=(he+he-2);n>=x;n--)
{
printf(" ");
}
for(c=0;c<=a;c++)
{
printf("* ");/* give a singal space after (*) */
}
x+=2;
printf("\n");
}
getch();
}
#include<conio.h>
main()
{
int he,gap,a,b,c,n,x=1;
clrscr();
printf("Enter the height of the pyramid\n");
scanf("%d",&he);/* give the value between 5 to 20 ,because screen not cover of pyramid size*/
gap=he-1;
for(a=1;a<=he;a++)
{
for(n=1;n<=he;n++)
{
printf(" ");
}
for(c=gap;c>=a;c--)
{
printf(" ");
}
for(b=1;b<=a;b++)
{
printf("* ");/* give a singal space after (*) */
}
printf("\n");
}
for(a=0;a<he;a++)
{
for(b=gap;b>a;b--)
{
printf(" ");
}
for(c=0;c<=a;c++)
{
printf("* ");/* give a singal space after (*) */
}
for(n=(he+he-2);n>=x;n--)
{
printf(" ");
}
for(c=0;c<=a;c++)
{
printf("* ");/* give a singal space after (*) */
}
x+=2;
printf("\n");
}
getch();
}
If you do not understand this program, then comment, I will send you a link to a video. Although this program is definitely a bit tough, but it can be easily understood. And you have to give a single space after every * in the program, otherwise the pyramid will not be completely printed. But if you still have any problem, then you can ask us in the comment. Let's see the fourth program.
4. Triangle Program In C Language 2021.
This program has also been asked many times in the exam, so we hope that you will understand this program very well. In this program i connected two 90 degree triangle each-other. When you see its output, you will understand what is the logic of this program, although this program is similar to all the above programs, then you will not have any problem in understanding . This program is also user based, which means that the program will not run until the user enters a value. See this output.pyramid pattern In C language 2021 |
#include<stdio.h>
#include<conio.h>
main()
{
int x,y,z,a,b;
clrscr();
printf("Enter length of pattern\n");
scanf("%d",&z);
x=z;
y=z;
for(a=1;a<=z;a++)
{
for(b=1;b<z*2;b++)
{
if(b>x && b<y)/*And operator*/
{
printf(" ");/*single space */
}
else
{
printf("*");/* do not space after(*) */
}
}
x--;
y++;
printf("\n");
}
getch();
}
#include<conio.h>
main()
{
int x,y,z,a,b;
clrscr();
printf("Enter length of pattern\n");
scanf("%d",&z);
x=z;
y=z;
for(a=1;a<=z;a++)
{
for(b=1;b<z*2;b++)
{
if(b>x && b<y)/*And operator*/
{
printf(" ");/*single space */
}
else
{
printf("*");/* do not space after(*) */
}
}
x--;
y++;
printf("\n");
}
getch();
}
To make this program, we have used 5 variables, so that the triangle pattern can be improved. Only for loop is used in this program. We hope you liked this program. Let's see our last program.
5. Square Pattern In C programming 2021 .
This is the most simple program in this post, in this program we will learn to draw a square. This program is known to almost all people. No problem even if you do not know. Now you will learn this program easily. First of all, see the output of this program.square program in C language 2021 |
#include<stdio.h>
#include<conio.h>
main()
{
int y=9,x=y/2+1,a,b;
clrscr();
for(a=1;a<=y;a++)
{
for(b=1;b<=y;b++)
{
if(b==x||b==y-x+1)
{
printf("*");
}
else
printf(" ");
}
if(a<=y/2)
x--;
else
x++;
printf("\n");
}
getch();
}
#include<conio.h>
main()
{
int y=9,x=y/2+1,a,b;
clrscr();
for(a=1;a<=y;a++)
{
for(b=1;b<=y;b++)
{
if(b==x||b==y-x+1)
{
printf("*");
}
else
printf(" ");
}
if(a<=y/2)
x--;
else
x++;
printf("\n");
}
getch();
}
You must have seen that we have used 4 variables to create this program, so you can copy and run this program by pasting it into any C IDE. If you have any problem, you can comment.
So friends, these were the top 5 programs in C language-2020, we hope you will like all these programs, if you like this post, then you will definitely tell me by commenting, and do not forget to share this post, as well as Make sure to subscribe the blog through E-Mail, so that whenever a new post arrives on the blog, its notification can reach you.
* SHARE WITH FRIENDS *
Tags :
pattern program in c basic,
christmas tree pattern program in c,
c program pattern using for loop,
c program for pattern of stars,
c program to generate pattern of stars,
pattern program in c with explanation,
1 Comments
Thanks For Sharing The Amazing content. I Will also share with my friends. Great Content thanks a lot.
ReplyDeleteTernary Operator In C
Hey , Comment Your Query or Suggestion