Saturday, March 19, 2016

C Program to perform Arithematic Operation using function

/*=================================================================================
**
**  File Name     : mathOpe.c
**  Creation Date : Sat 19 Mar 2016 05:25:39 AM IST
**  Last Modified : Sat 19 Mar 2016 05:43:16 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**================================================================================*/
#include<stdio.h>
int addition(int x, int y);
int subtraction(int x, int y);
int multiplication(int x, int y);
int division(int x, int y);
int main()
{
    printf("\n= = = = = Arithematic Operation using function = = = = =\n");
    int n1, n2, sum, sub, mul, div;
    printf("\nEnter the value of 'n1' : ");
    scanf("%d",&n1);
    printf("Enter the value of 'n2' : ");
    scanf("%d",&n2);
    sum = addition(n1,n2);
    printf("\nThe sum of %d and %d is : %d\n",n1,n2,sum);
    sub = subtraction(n1,n2);
    printf("The subtraction of %d from %d is : %d\n",n2,n1,sub);
    mul = multiplication(n1,n2);
    printf("The multiplication  of %d and %d is : %d\n",n1,n2,mul);
    div = division(n1,n2);
    printf("The division of %d by %d is : %d",n1,n2,div);
    printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");

}
int addition(int x, int y)
{
    int k;
    k = x+y;
    return k;
}
int subtraction(int x, int y)
{
    int k;
    k = x-y;
    return k;
}
int multiplication(int x, int y)
{
    int k;
    k = x*y;
    return k;
}
int division(int x, int y)
{
    int k;
    k = x/y;
    return k;
}

OutPut:

max@ubuntu:~/cprog$ gcc mathOpe.c -o mathOpe
max@ubuntu:~/cprog$ ./mathOpe

= = = = = Arithematic Operation using function = = = = =

Enter the value of 'n1' : 10
Enter the value of 'n2' : 4

The sum of 10 and 4 is : 14
The subtraction of 4 from 10 is : 6
The multiplication  of 10 and 4 is : 40
The division of 10 by 4 is : 2

= = = = = = = = = = = = = = = = = = = = = = = = = = = = =

No comments:

Post a Comment