FranciscoSoccol

Lista 09 - Exercicio 06

Sep 8th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.     if(strcmp(*(argv+2),"+")==0)
  7.         printf("\n%d",atoi(*(argv+1))+atoi(*(argv+3)));
  8.  
  9.     else if(strcmp(*(argv+2),"-")==0)
  10.         printf("\n%d",atoi(*(argv+1))-atoi(*(argv+3)));
  11.  
  12.     else if(strcmp(*(argv+2),".")==0)//mudei para ponto pois o prompt nao reconheceu o *
  13.         printf("\n%d",atoi(*(argv+1))*atoi(*(argv+3)));
  14.  
  15.     else if(strcmp(*(argv+2),"/")==0 && atoi(*(argv+3))!=0)
  16.         printf("\n%f",atof(*(argv+1))/atoi(*(argv+3)));
  17.  
  18.     else
  19.         printf("\nErro! divisao por zero");
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment