Search This Blog

Loading...

C program - Addition,Subtraction,Multiplication and Division of two number


Write a program that input two numbers and prints addition,subtraction,multiplication and division.

#include<stdio.h>
#include<conio.h>

void main()
{
    int a,b,sum,sub,mul,div;
    clrscr();
   
    printf("Enter number a=");
    scanf("%d \n",&a);
   
    printf("Enter number b=");
    scanf("%d \n",&b);
   
    sum=a+b;   //This will perform addition.
    sub=a-b;
     //This will perform subtraction. 
    mul=a*b;    //This will perform multiplication.
    div=a/b;     //This will perform division.   
    printf("Sum = %d \n",sum);
    printf("Sub = %d \n",sub);
    printf("Mul = %d \n",mul);
    printf("Div = %d \n",div);
   
    getch();
}


Output:
Enter number a=5
Enter number b=3
Sum = 8
Sub = 2
Mul = 15
Div = 1

1 comment:

  1. You can get nearly 200 to 300 c - programs on www.vitedu.in. Try it.

    ReplyDelete