Last active
April 30, 2018 19:18
-
-
Save sayantanHack/08039fdfd255317be6b4aafe1c615c22 to your computer and use it in GitHub Desktop.
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
#include<stdio.h> | |
#include<cs50.h> | |
#include<string.h> | |
int main(int argc, string argv[]) | |
{ | |
if(argc!=4){ | |
return 1; | |
} | |
float s,a = atof(argv[1]),b = atof(argv[3]); | |
int q; | |
if(argv[2][0] == '+'){ | |
s = a + b; | |
printf("The sum is : %f\n",s); | |
return 0; | |
} | |
else if(argv[2][0] == '-'){ | |
s = a - b; | |
printf("The substraction is : %f\n",s); | |
return 0; | |
} | |
else if(argv[2][0] == 'x'){ | |
s = a * b; | |
printf("The multiplication is : %f\n",s); | |
return 0; | |
} | |
else if(argv[2][0] == '/'){ | |
s = a / b; | |
printf("The division is : %f\n",s); | |
return 0; | |
} | |
else if(argv[2][0] == '%'){ | |
q = (int)(a/b); | |
s = a - (b*q); | |
printf("The modulo is : %f\n",s); | |
return 0; | |
} | |
else | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment