Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Keanu Toomer
- Date: 20/01/2019
- Purpose: Prints the day of the week that corresponds to the number inputted
- */
- #include "stdafx.h"
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int num; //Declaring an integar variable
- printf("Enter your number "); //Prompting user for an input
- scanf_s("%d", &num); //Scanning for their integer input and assigning it to num
- switch (num) //Opening switch-case with num
- {
- case 1: //If num is equal to 1
- printf("\nMonday\n");
- break;
- case 2: //If num is equal to 2
- printf("\nTuesday\n");
- break;
- case 3: //If num is equal to 3
- printf("\nWednesday\n");
- break;
- case 4: //If num is equal to 4
- printf("\nThursday\n");
- break;
- case 5: //If num is equal to 5
- printf("\nFriday\n");
- break;
- case 6: //If num is equal to 6
- printf("\nSaturday\n");
- break;
- case 7: //If num is equal to 7
- printf("\nSunday\n");
- break;
- default: //If num is greater than 7 or less than 1
- printf("\nThat number does not corrospond to a day of the week\n");
- break;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement