Created
August 8, 2019 17:54
-
-
Save abhisekpadhi/6b4c5b08d20fe60eac5e0016519ece78 to your computer and use it in GitHub Desktop.
c_operators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Learning operators | |
#include <stdio.h> | |
float sum(int a, float b){ | |
float sum=0; | |
sum = a + b; | |
return sum; | |
} | |
float diff(float a, float b){ | |
float diff=0; | |
diff = a - b; | |
return diff; | |
} | |
float mul(float a, float b){ | |
float mul=0; | |
mul = a * b; | |
return mul; | |
} | |
float division(float a, float b){ | |
float div = 0; | |
div = a / b; | |
return div; | |
} | |
int mod(int a, int b){ | |
int mod = 0; | |
mod = a % b; | |
return mod; | |
} | |
main(){ | |
printf("%f\n", sum(5, 6)); // 11.0 | |
printf("%f\n", diff(6, 5)); // 1.0 | |
printf("%f\n", mul(6, 5)); // 30.0 | |
printf("%f\n", division(8, 0)); // 4.0 | |
printf("%d\n", mod(8, 2)); //0.0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment