fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void){
  5. char op;
  6. int first, second;
  7.  
  8. printf("Enter operation\n");
  9. if(3 != scanf("%d %c %d", &first, &op, &second)){
  10. fprintf(stderr, "invalid input.");
  11. exit(EXIT_FAILURE);
  12. }
  13. if(op == '+'){
  14. int add = first + second;
  15. printf("Sum = %d\n",add);
  16. }
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 2172KB
stdin
1 + 2
stdout
Enter operation
Sum = 3