You are on page 1of 2

------------------------------------------------------------------------------------------------------------------------------Problem: Function that perform basic arithmetic operation i.e.

Addition, Subtraction,
Multiplication and Division.
------------------------------------------------------------------------------------------------------------------------------#include <conio.h>
#include <stdio.h>
void add(int,int);
void sub(int,int);
void mul(int,int);
void div(int,int);
void main()
{
clrscr();
int n1,n2;
printf("Enter the 1st no: ");
scanf("%d",&n1);
printf("\nEnter the 2nd no: ");
scanf("%d",&n2);
add(n1,n2);
sub(n1,n2);
mul(n1,n2);
div(n1,n2);
getch();
}
void add(int n1, int n2)
{
printf("\n%d + %d = %d",n1,n2,n1+n2);
}
void sub(int n1, int n2)
{
printf("\n%d - %d = %d",n1,n2,n1-n2);
}
void mul(int n1, int n2)
{
printf("\n%d * %d = %d",n1,n2,n1*n2);
}

void div(int n1, int n2)


{
if(n2==0)
printf("\n%d/%d is Undefine",n1,n2);
else
printf("\n%d / %d = %d",n1,n2,n1/n2);
}

URL: http://mylcphs.com/ics.html
E-Mail: farhan.saleem@hotmail.com
Instructor: Muhammad Rana Farhan

You might also like