Last active
August 29, 2015 14:17
-
-
Save jalcine/b307222eab06e5c5f5d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS // turn off SAFE COMMANDS | |
// ############################ | |
// Written By: Cristian Colocho | |
// Date Written: March, 14, 2015 | |
// Purpose: Loop Menu and Switch | |
// ############################ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define PAUSE system("pause"); | |
main(){ | |
// Declare Variables | |
int choice, number, cubed, square; | |
int count = 1; | |
// Display Menu Options | |
do { | |
printf("Select an option: \n" | |
"1. Enter a number\n" | |
"2. Cube the number\n" | |
"3. Square the number\n" | |
"4. Display Even or Odd\n" | |
"5. Quit/n" | |
); | |
scanf("%d", &choice); | |
// Menu Options | |
if (choice == 1) { | |
printf("Enter a number: \n"); | |
scanf("%i", &number); | |
printf("Your number is: %i", number); | |
} | |
else if (choice == 2) { | |
cubed = number * number * number; | |
printf("%i cubed is %i", number, cubed); | |
} | |
else if (choice == 3) { | |
square = number * number; | |
printf("%i squared is %i", number, square); | |
} | |
else if (choice == 4) { | |
if (number%2 == 0) | |
printf("%i is Even\n", number); | |
else | |
printf("%i is Odd\n", number); | |
} | |
else if (choice == 5) { | |
system("pause"); | |
} | |
else { | |
printf("Invalid Choice"); | |
} | |
} while (choice != 5); | |
PAUSE | |
} // end main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment