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, _______ ______ ____ __________ _______.
__________ ___ _______ ___ ______ ________.
______ _________ _________ __________ ___ _______ __________ ____ _______ _______.
________ ____ __________ ________ ___ __________ _________ ________ ____ _______ _________ ___.
_________ ________ ________ _____ __________ ________ ____ __________ __________ _________ ________.
_______ _____ ________ ___ _________ ___.
_________ _________ ________ __________ ____ __________ _________ ____ ________ ____ __________ ____.
________ _____ _______ ______ ________ __________ _______ _______.
____ _________ _______ _____ __________ _________ ____ _______.
_____ __________ ___ ______ _____ ____ ___ ______ __________ ______ __________.
______ ___ _________ ______ ________ __________ _____ ______ ________ ______.
___ _______ _______ ___ _____ _________ _______ ______ _______ _____.
__________ _______ ________ __________ ____ _______ _____ ____.
__________ ____ _____ __________ ___.
_______ ______ ________ ______ ________ ________ ___ _______.
_____ ___ __________ ______ ______ ___ _______ ______ ________ _______.
________ ___ ____ ____ ______ ______ _________ _____.
______ ___ ____ _________ ___ _______ __________ ______ ________.
_____ __________ _______ _______ __________ _______ ___ _______ ________ ____ ______.
____ __________ ___ _____ ________ _________.
________ ______ ________ ___ ______ _____ _____ ________ _________.
__________ ___ _____ _____ ____ ______ __________ __________ ________ _________.
____ ________ _______ ___ _________.
______ ___ ___ _____ _______ _____ _____ ___ _________ ______ ___ ________.
_______ ______ ______ __________ ________ ______ _________ ___ _________ ____ ___ _________.
_________ ______ _______ _________ ___ ________ ___ ______.
___ ______ _________ _______ ______ ______ _______ ___ _____ _________.
______ ________ _____ _____ _______ _______ __________.
_____ ____ _____ ________ _______ ___ _____ __________ ___ ______ __________ ______.
_____ __________ _______ ________ ____ ______ ________ _________ _________ _____ ____.
____ _____ __________ ____ ____ __________ ______ ________ _________.
_____ _____ _________ _________ ________ __________ _________ _______ _____ ______.
__________ _________ ________ _______ ____ ___ _____.
_________ ________ _____ __________ ___ _________ _______ _________ ______.
______ __________ ___ ________ _____ ________ ________ __________ _____.
___ ______ ______ __________ _________ __________ __________ ________ _________ __________ _________ _____.
________ ________ _______ ________ _____.
___ _________ _______ ___ _____ ____ ______ _________ __________ _______.
__________ __________ _____ _____ ______ ______ ________.
_______ _________ _________ ________ ______ ________ ______ _________ __________.
__________ _________ _________ ___ ___ ______ ___.
_______ __________ _________ _____ _________ ________ ______ _____ _________.
___ ___ ________ ____ _____ _________ _________ __________.
___ ________ ___ ________ ___ __________ ______ _______ _________ ________ ___.
________ ________ ____ _____ ___ _______ ________ ______ ____ __________ ____.
__________ _________ _______ _________ _____ ____ _____ ________ ____.
______ ____ ________ ________ _____ _________ __________ ___ _______ _________ __________ __________.
______ ______ __________ ________ _____ ___ _______.
____ ___ ___ _______ ___ ______ _________ _________ ________ __________.
______ ______ ______ __________ ________ __________ __________.
__________ _______ _________ ___ ________.
_____ ___ _______ __________ ___ ____ __________ ____.
_______ ____ _________ ____ _______ ________ ________ ________.
___ ______ _________ ____ ______ __________ ________ ___ ___ _______ _____ _______.
___ __________ __________ ___ _________ ________ ______ ________ _________ ____ ___ ___.
_______ _________ __________ __________ _________ _________ ________ ___ _____ _________ _______.
_______ ___ ______ _____ _______ __________ ___ _____ ____ _________.
_____ __________ ___ ____ __________ ______ ______ ____ _______ ______ _______.
_______ ___ __________ ______ __________ ______ _________.
__________ _________ _________ _____ ________.
_________ _____ _______ _________ ______ ___.
___ _____ ______ ___ _____ _________ _______ ________ _____ __________ ______.
___ ________ ______ ____ __________ _________.
__________ ___ ____ _____ ____ _____ ___ ________ _____ __________.
_________ ____ __________ ___ _____ __________.
_____ ______ ____ ____ ______ __________ _________ _______ __________ _________ _______ _______.
_______ ___ ______ _______ _______ _____.
________ ___ __________ ____ ______.
__________ ___ _____ ________ ___ __________ ________ _______ ________ __________ ___.
__________ _______ ______ ______ ________ ______ __________ _____ ____ _______.
_____ ________ _________ _____ ______ __________.
_____ ______ _________ _______ _________ _______ _________.
_____ ___ ____ __________ ___ _________ ______.
__________ __________ ___ _________ ___ ____ __________ ___.
_____ _____ _________ __________ ______ ________ _________ __________ ___.
________ _______ ________ _____ _______ ______ _____ ______ ______ _________.
_____ __________ _____ ____ ____ _____ __________ ________ _______ ______ _______ ________.
_______ ______ ___ _______ __________ _____ ______ __________ _________ _________ _____.
Get Full Answer on WhatsApp