SHARE
TWEET

x.c

Turpo-Urpo Jun 22nd, 2020 (edited) 1,391 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. int main(int argc,char* argv[]) {
  7.     char* x1 = argv[2]; float f1 = atof( x1 );
  8.    
  9.     for(int i = 3; i < argc; i++) {
  10.         char* x2 = argv[i];
  11.         float f2 = atof( x2 );
  12.        
  13.         if(strcmp(argv[1], "/") == 0) {
  14.         printf("%.2lf / %.2lf = %.2lf\n",f2, f1, f2/f1); }
  15.  
  16.         if(strcmp(argv[1], "+") == 0) {
  17.         printf("%.2lf + %.2lf = %.2lf\n",f2, f1, f2+f1); }
  18.  
  19.         if(strcmp(argv[1], "-") == 0) {
  20.         printf("%.2lf - %.2lf = %.2lf\n",f2, f1, f2-f1); }
  21.  
  22.         if(strcmp(argv[1], "*") == 0) {
  23.         printf("%.2lf * %.2lf = %.2lf\n",f2, f1, f2*f1); }
  24.  
  25.         }
  26.    
  27.     return 0;
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top