/* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : Programs On Function. */ #include<stdio.h> /******** declaring function **********/ float sum(float n,float m); float sub(float n,float m); float mul(float n,float m); float div(float n,float m); void main() { float x,y; char s; scanf("%f %c %f",&x,&s,&y); /********* switch statement **********/ switch(s) { case '+': printf("%f",sum(x,y)); break; case '-': printf("%f",sub(x,y)); break; case '*': printf("%f",mul(x,y)); break; default: printf("%f",div(x,y)); break; } } /******** defining function **********/ float sum(float n,float m) { return n+m; } float sub(float n,float m) { return n-m; } float mul(float n,float m) { return n*m; } float div(float n,float m) { return n/m; }
Output:
8
*
9
72.000000