100% found this document useful (1 vote)
458 views2 pages

Function Add Sub Mul Div

The program defines functions to perform basic arithmetic operations - addition, subtraction, multiplication and division. It takes two numbers as input from the user, calls the respective functions to calculate the results and prints them. For division, it checks if the denominator is zero to avoid undefined results.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
458 views2 pages

Function Add Sub Mul Div

The program defines functions to perform basic arithmetic operations - addition, subtraction, multiplication and division. It takes two numbers as input from the user, calls the respective functions to calculate the results and prints them. For division, it checks if the denominator is zero to avoid undefined results.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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: [email protected]
Instructor: Muhammad Rana Farhan

You might also like