Arithmetic operation using function

C program to perform arithmetic operation using function:

code

#include<stdio.h>

#include<conio.h>

void cal(int,int);

void main()

{

int a,b;

clrscr();

printf(“Enter first element :”);

scanf(“%d”,&a);

printf(“Enter second element :”);

scanf(“%d”&b);

cal(a,b);

getch();

}

void cal(int x,int y)

{

int add,sub,div,mul;

add=x+y;

sub=x-y;

div=x/y;

mul=x*y;

printf(“\nResult of arithmetic operations :\n”);

printf(“Addition : %d”,add);

printf(“\subtraction :%d”,sub);

printf(“\nDivision :%d”,div);

printf(“\nMultiplication :%d”,mul);

return 0;

}

 


output

Enter first element :34

Enter second element :30

Result of arithmetic operations :

Addition :64

Subtraction :4

Division :1

Multiplication :1020

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s