Write a menu driven program(using switch-case) which accepts a number as user input : A) Checks whether the number is even or odd B) Checks whether the number is prime
To create a menu-driven program in C++ that checks whether a number is even or odd and whether it's prime, you can use a switch-case statement. Here's a practical implementation of such a program:
```cpp
#include <iostream>
#include <cmath>
using namespace std;
// Function to check if a number is even
bool isEven(int num) {
return num % 2 == 0;
}
// Function to check if a number is prime
bool isPrime(int num) {
if (num <= 1) return false;
if (num <= 3) return true;
for (int i = 5; i * i <= num; i += 6) {
if (num % i == 0 || num % (i + 2) == 0) return false;
}
return true;
}
int main() {
int choice, number;
do {
// Display the menu
cout << "Menu:" << endl;
cout << "1. Check if a number is even" << __________ ___ _____ _____ ______ ______ ____ ______.
_______ ___ _________ _____ _______ ________.
_____ _________ __________ ____ ________ __________ _________ _____ _______ _________.
_______ _________ ____ ____ ____ ____ ___ ________ ____ _______.
_______ _____ ________ ______ _____ ______ _________ ________ __________ _______ ___ ________.
______ ____ ________ ______ ______ __________ ________ _____.
_____ __________ __________ ________ _________ _______ _____ _______ __________.
_______ ____ __________ _________ ___ _________ _______ _________ _____.
__________ __________ _____ ______ ________.
_________ ______ _________ __________ _______ __________ ________ ______ _____.
____ ________ ______ ___ ____ _________ ________.
__________ ________ __________ ________ _____ _________ _____ _______ ___ ______.
_______ _________ ______ ____ ______ _______ __________ ___ _____.
_______ ______ ________ __________ ______ __________ ______ ______ __________.
______ ___ __________ __________ ____ ______.
___ ___ _________ ___ ____.
__________ _______ _______ ________ ________ _______ __________ __________ _________ _____.
___ _______ _____ ___ __________ __________ ____.
__________ __________ ___ __________ ___ _______ __________ ___ _________ _________ __________ ________.
_____ ___ _______ ___ _________ __________ _______ _____ __________ ______.
_________ _________ _________ _________ ___ ____ _____ __________ ______ _____.
____ ____ _________ ___ ___ _______ ___ ______.
______ _____ ___ _______ _______ _____ ___ ______ ______ ___ ____ ________.
______ ______ ___ _______ __________.
_____ _________ ____ __________ ________ _______ _________ _____ _______ __________.
_____ _____ _____ _____ _______ ________ ___ __________ __________ ________ _______.
_________ ________ ______ ______ __________ ____ _________.
_______ _______ _______ _____ ______ ____ ______ ____ __________ _______ ______.
_______ ____ _________ ________ _____ _____ __________ ________ _______.
___ ____ __________ ______ __________ ____ _______ ____ ______ ___ __________ ____.
_____ ___ ______ ____ _______ ___ ________ _____ ______ ________ __________.
______ _______ _________ _____ ____ _________.
____ _________ ______ ____ ____ ______ _______ ________ _________ _______.
______ _________ ______ ____ __________ ______ ___.
____ ___ ___ ___ __________ _____ ____ ______ _________ __________ _________.
__________ _______ __________ ________ _________ _______.
___ ____ ________ ______ _____ ____ ___ ________ ___ ____ _______ _____.
_____ __________ __________ _____ ______ _____ _______ ________ ____ ________ ______ _________.
________ _________ ________ __________ __________ ___.
_______ _____ ___ ___ _________ _____ _______ _______ ____ ____.
___ __________ ______ ____ _______ ______ ______ ______ _______ _______ _____.
________ ____ _____ _____ ___ ___.
_______ _______ _______ ________ ____ _________ ___ _________ _________ ____ _____ ____.
________ ______ _____ ____ _____.
________ ___ ____ ________ ________ ___ _________ ______ _______ _____ ______.
____ _________ ____ __________ __________.
___ __________ _______ __________ ___ ________ __________.
______ ____ _______ ______ ________ _________ ___ __________ ________.
_______ ____ _______ __________ __________ ______.
________ _________ _______ _________ ______ ______ _______ __________ _____ ______.
___ ______ _______ _________ ____ __________ __________ ____.
__________ ___ ________ __________ _______ _________ ____.
_________ ____ ______ _________ ________.
_________ _________ ________ ____ __________ ________ ___ ______ _____ ___.
___ ___ ____ ___ ______ ___ ____ _____ ___ _________.
_________ _____ ___ ______ __________ ________ ____ ____ ______ ___.
_______ ___ ________ ________ ___ _________.
____ __________ ________ _______ ________ _______ ___ _________ _________ ________ ________.
_____ ________ _____ __________ ______ ______ _________ _______ ____.
_____ _______ ______ ________ _________ ______ ____.
______ ___ __________ __________ ______ _________ _______ ____ ______.
______ ______ ________ ______ __________ __________ _________ _________.
__________ _______ _______ __________ __________ ____ ______ ________ _____ ________ ____ _________.
____ _____ _______ _________ ____ _____.
____ _____ ______ ____ _______.
__________ _________ _____ _______ _________ ___ _____.
_____ ________ ___ _________ _______.
____ _______ ____ ______ ________ ______.
___ ____ __________ ________ ___ _________ ______ ___.
________ _______ _______ _________ _____ ___ _________ __________ ____ ___.
______ _____ _______ ______ ______ ___ ________ ___ _____.
____ _______ ___ ____ ___ _______ ___.
_____ ____ ______ ____ _________.
_______ ___ _______ __________ ____ ___ ______.
_______ _________ _____ ______ _______.
__________ _________ __________ ____ _________.
______ ____ ________ _________ _______ ______.
___ __________ _____ ____ ___.
Get Full Answer on WhatsApp