Ad Code

10 Basic programs in C Language



1:  Addtion of two number in C Language-:

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int num1,num2,addtion;

printf("enter the num1 value");

scanf("%d",&num1);    //scan num1 value

printf("enter the num2 value");

scanf("%d",&num2);   //scan num2 value

addtion=num1+num2;

printf("Addtion is=%d",addtion);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the num1 value 25             // after write 25 press enter key
enter  the num2 value 5
Addtion is=30

2: Multiplication of two number in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int num1,num2,multiplication;

printf("enter the num1 value");

scanf("%d",&num1);    //scan num1 value

printf("enter the num2 value");

scanf("%d",&num2);   //scan num2 value

multiplication=num1*num2;

printf("Multiplication is=%d",multiplication);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the num1 value 25             // after write 25 press enter key
enter  the num2 value 5
multiplication is=125

3:  Subtraction of two number in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int num1,num2,subtraction;

printf("enter the num1 value");

scanf("%d",&num1);    //scan num1 value

printf("enter the num2 value");

scanf("%d",&num2);   //scan num2 value

subtraction=num1-num2;

printf("Subtraction is=%d",subtraction);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the num1 value 25             // after write 25 press enter key
enter  the num2 value 5
Subtraction is=20

4 :  Division of two number in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int num1,num2,division;

printf("enter the num1 value");

scanf("%d",&num1);    //scan num1 value

printf("enter the num2 value");

scanf("%d",&num2);   //scan num2 value

division=num1/num2;

printf("Division is=%d",division);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the num1 value 25             // after write 25 press enter key
enter  the num2 value 5
Subtraction is=5

5:  Modulus of two number in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int num1,num2,modulus;

printf("enter the num1 value");

scanf("%d",&num1);    //scan num1 value

printf("enter the num2 value");

scanf("%d",&num2);   //scan num2 value

modulus=num1 % num2;

printf("Modulus is=%d",modulus);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the num1 value 25             // after write 25 press enter key
enter  the num2 value 5
Modulus is=0
6:  Area of Circle in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int  Radious,Area_of_Circle;    //variables

printf("enter the Radious of Circle");

scanf("%d",&Radious);   //scan Radious value

Area_of_Circle=3.14*Radious*Radious;      // Formula

printf("Area_ of _Circle is=%d",Area_of_Circle);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

 enter  Radious of Circle 5          // after write 5 press enter key
 Area_of_Circle is= 78

7:  Area of Triangle in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int Height,Width,Area_of_Triangle;    //variables

printf("enter  the Height of Triangle  ");

scanf("%d",&Height);   //scan value

printf("enter  the Width of Triangle  ");

scanf("%d",&Width); 

Area_of_Triangle=(Height*Width)/2;      // Formula

printf("Area_ of _Triangle is=%d",Area_of_Triangle);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter  the Height of Triangle 5          // after write 5 press enter key
enter  the Width of Triangle 5   
 Area_of_Circle is= 12.5

8:  Swaping of two number program in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int num1,num2,Swap;

printf("enter the num1 value");

scanf("%d",&num1);    //scan num1 value

printf("enter the num2 value");

scanf("%d",&num2);   //scan num2 value

Swap=num1 ;

num1=num2;

num2=Swap;

printf("After Swaping num1 = %d",num1);    //print output 

printf("After Swaping num2 = %d",num2);

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the num1 value 25             // after write 25 press enter key
enter  the num2 value 5
After Swaping num1=5
After Swapring num2=25

9:  Gross_Salary program in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

int gross_salary,basic,ta,da,hra;

printf("enter the basic salary");

scanf("%d",&basic);    //scan num1 value

da=(10*basic)/100;

ta=(14*basic)/100;

hra=(20*basic)/100;

gross_salary=basic+ta+da+hra;

printf("Gross salary  = %d",gross_salary);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the basic salary 25             // after write 25 press enter key
Gross salary =35

10: Simple intrest  program in C Language-:)

#include<stdio.h>      //standerd i/o header_file

#include<conio.h>    //console input output header_file

int main()

{

float principal,rate,time;

float simple_intrest;

printf("enter the principal = ");

scanf("%f",&principal);    //scan  value

printf("enter the rate = ");

scanf("%f",&rate);   //scan  value

printf("enter the Time = ");

scanf("%f",&time);    //scan  value

simple_intrest=(principal*rate*time)/100;

printf("Simple intrest = %f",simple_intrest);    //print output 

getch();

return 0;

}

For run this program copy code and click- Run_program

Output:

enter the principal 25             // after write 25 press enter key
enter  the rate 5
enter the time 3
Simple intrest = 3.750000





Post a Comment

0 Comments

Coding with Annu