Advertisement
ohad

Untitled

Sep 12th, 2016
2,798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //------------------------------------------------------------------------------------------------------------------------------
  2. //                                                                  Exercise 8
  3. //                                                                  ----------
  4. //
  5. // General : The program will get two letters from the ABC. If the first letter shows before the second one at the ABC, the program will print the letter after the first one '+' the letter before the second one. Otherwise, the program will print the letter before the first one '-' the letter after the second one.
  6. //
  7. // Input   :  Two letters from the ABC.
  8. //
  9. // Process : Checks if the first letter entered comes before the second letter at the ABC. Prints its output according to that condition.
  10. //
  11. // Output  : Prints two letters and an operator according to the letters entered by the user.
  12. //
  13. //------------------------------------------------------------------------------------------------------------------------------
  14. // Programmer: Ohad Ozcohen
  15. // Date: 13.9.2016
  16. //------------------------------------------------------------------------------------------------------------------------------
  17.  
  18. #include <stdio.h>
  19.  
  20. void main(void)
  21. {
  22.     char Letter_one;
  23.     char Letter_two;
  24.     char operator = "+";
  25.     printf("Please enter a letter");
  26.     scanf_s("%c", &Letter_one);
  27.     fflush(stdin);
  28.     printf("Please enter a letter");
  29.     scanf_s("%c", &Letter_two);
  30.    
  31.     ((int)Letter_one < (int)Letter_two) ? printf("%c %c %c", (char)((int)Letter_one + 1), operator='+', (char)((int)Letter_two - 1)) : printf("%c %c %c", (char)((int)Letter_one - 1), operator='-', (char)((int)Letter_two + 1));
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement