Monday, 8 December 2014

program to check arithmatic operations
#include<stdio.h>
int sum(int,int);
int sub(int,int);
int mul(int,int);
int div(int,int);
int a=34,b=32;
int d,s,k,m;
main()
{
printf("inside main(): a and b are %d\t%d\n",a,b);
s=sum(a,b);
k=sub(a,b);
m=mul(a,b);
d=div(a,b);
}
int sum(int a,int b)
{
s=(a+b);
printf("sum of two numbers is %d\n",s);
}
int sub(int a,int b)
{
k=(a-b);
printf("substraction of two numbers is %d\n",k);
}
int mul(int a,int b)
{
m=(a*b);
printf("multiplication of numbers is%d:\n",m);
}
int div(int a,int b)
{
d=(a/b);
printf("division of two numbers is %d\n",d);
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ cc ex33.c
madan@madan-Lenovo-G570:~/madan$ ./a.out
inside main(): a and b are 34 32
sum of two numbers is 66
substraction of two numbers is 2
multiplication of numbers is1088:
division of two numbers is 1