fork(2) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void)
  4. {
  5. char card_name[3];
  6. puts("Enter the card name: ");
  7. scanf("%s", card_name);
  8. int val = 0;
  9. if (card_name[0] == 'K')
  10. {
  11. val = 10;
  12. }
  13. else if (card_name[0] == 'Q')
  14. {
  15. val = 11;
  16. }
  17. else if (card_name[0] == 'J')
  18. {
  19. val = 12;
  20. }
  21. else if (card_name[0] == 'A')
  22. {
  23. val = 13;
  24. }
  25. else
  26. {
  27. val = atoi(card_name);
  28. }
  29. printf("The card value is: %i\n", val);
  30. return 0;
  31. }
Success #stdin #stdout 0s 2252KB
stdin
Standard input is empty
stdout
Enter the card name: 
The card value is: 0