Search This Blog

Tuesday, 6 May 2014

C program for simple maths(+,-,*,/ etc...):-

C program for addition of two numbers:-

#include<stdio.h>
#include<conio.h>
 
void main()
{
   int a, b, c;
 
   printf("Enter two numbers to add\n");
   scanf("%d%d",&a,&b);
 
   c = a + b;
 
   printf("Sum of entered numbers = %d\n",c);
 
   getch();
}


C program for subtraction of two numbers:-

#include<stdio.h>
#include<conio.h>
 
void main()
{
   int a, b, c;
 
   printf("Enter two numbers to subtract\n");
   scanf("%d%d",&a,&b);
 
   c = a - b;
 
   printf("subtraction of entered numbers = %d\n",c);
 
   getch();
}


C program for multipication of two numbers:-

#include<stdio.h>
#include<conio.h>
 
void main()
{
   int a, b, c;
 
   printf("Enter two numbers to multiply\n");
   scanf("%d%d",&a,&b);
 
   c = a * b;
 
   printf("multipication of entered numbers = %d\n",c);
 
   getch();
}





C program for division of two numbers:-
#include<stdio.h>
#include<conio.h>
 
void main()
{
   int a, b, c;
 
   printf("Enter two numbers to divide\n");
   scanf("%d%d",&a,&b);
 
   c = a / b;
 
   printf("division of entered numbers = %d\n",c);
 
   getch();
}

C program to calculate area of a circle:-
#include<stdio.h>
#include<conio.h>
 
void main()
{
   float radius, area;
 
   printf("Enter the radius of circle\n");
 
   scanf("%f",&radius);
 
   area = 3.14*radius*radius;  
 
   printf("Area of circle = %f\n",area);
 
   getch();
}

Ask any Questions in Comments :-)