Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. /*
  2. Author: Keanu Toomer
  3. Date: 20/01/2019
  4. Purpose: Prints the day of the week that corresponds to the number inputted
  5. */
  6.  
  7. #include "stdafx.h"
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11.  
  12. int main()
  13. {
  14.     int num; //Declaring an integar variable
  15.  
  16.     printf("Enter your number "); //Prompting user for an input
  17.     scanf_s("%d", &num); //Scanning for their integer input and assigning it to num
  18.  
  19.     switch (num) //Opening switch-case with num
  20.     {
  21.         case 1: //If num is equal to 1
  22.             printf("\nMonday\n");
  23.             break;
  24.         case 2: //If num is equal to 2
  25.             printf("\nTuesday\n");
  26.             break;
  27.         case 3: //If num is equal to 3
  28.             printf("\nWednesday\n");
  29.             break;
  30.         case 4: //If num is equal to 4
  31.             printf("\nThursday\n");
  32.             break;
  33.         case 5: //If num is equal to 5
  34.             printf("\nFriday\n");
  35.             break;
  36.         case 6: //If num is equal to 6
  37.             printf("\nSaturday\n");
  38.             break;
  39.         case 7: //If num is equal to 7
  40.             printf("\nSunday\n");
  41.             break;
  42.         default: //If num is greater than 7 or less than 1
  43.             printf("\nThat number does not corrospond to a day of the week\n");
  44.             break;
  45.     }
  46.    
  47.     system("pause");
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement