Advertisement
Guest User

mee1

a guest
Feb 16th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. int main()
  5. {
  6.     int a, b;
  7.     uint8_t sel;
  8.    
  9.     printf( "1. Add\n" );
  10.     printf( "2. Sub\n" );
  11.     printf( "3. Mul\n" );
  12.     printf( "4. OR\n" );
  13.     printf( "5. AND\n" );
  14.     printf( "6. XOR\n" );
  15.     printf( "\nSelection: " );
  16.     scanf( "%hhu", &sel );
  17.     getchar();
  18.     printf( "a=" );
  19.     scanf( "%d", &a );
  20.     getchar();
  21.     printf( "b=" );
  22.     scanf( "%d", &b );
  23.     getchar();
  24.        
  25.     if ( sel == 1 ) {
  26.         printf( "result: %d\n", a + b );
  27.     } else if ( sel == 2 ) {
  28.         printf( "result: %d\n", a - b );
  29.     } else if ( sel == 3 ) {
  30.         printf( "result: %d\n", a * b );  
  31.     } else if ( sel == 4 ) {
  32.         printf( "result: %d\n", a | b );
  33.     } else if ( sel == 5 ) {
  34.         printf( "result: %d\n", a & b );
  35.     } else if ( sel == 6 ) {
  36.         printf( "result: %d\n", a ^ b );
  37.     } else {
  38.         printf( "No action.." );
  39.     }
  40.    
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement