Skip to content

Instantly share code, notes, and snippets.

@abhisekpadhi
Created August 8, 2019 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhisekpadhi/6b4c5b08d20fe60eac5e0016519ece78 to your computer and use it in GitHub Desktop.
Save abhisekpadhi/6b4c5b08d20fe60eac5e0016519ece78 to your computer and use it in GitHub Desktop.
c_operators
//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