Question

Write a menu driven program (using switch-case) which accepts a number as user input: A) Prints sum of digits of the given number B) Prints reverse of the given number.

02 Apr 2022
Answer :
Word Count : 621

Creating a menu-driven program using a switch-case statement in a programming language like C++ will allow us to achieve the tasks of calculating the sum of digits and reversing a given number. Below is an example in C++ to fulfill this requirement:

```cpp
#include <iostream>
using namespace std;

// Function to calculate the sum of digits of a number
int sumOfDigits(int number) {
    int sum = 0;
    while (number != 0) {
        sum += number % 10;
        number /= 10;
    }
    return sum;
}

// Function to reverse the given number
int reverseNumber(int number) {
    int reversedNumber = 0;
    while (number != 0) {
        reversedNumber = reversedNumber * 10 + number % 10;
      ______ _____ _______ ___ ______ _________ ___ _______ ______.
__________ _____ _________ _____ ____.
______ ______ ______ _____ _________ ______ _______ _____ _____ ___ __________.
____ __________ ____ _______ ________ ______ __________ ______ ________ ____ ____ ____.
_______ _______ ___ __________ _________ _______ __________ ________ _________ _______ _________.
____ ___ _______ __________ _____ _______ ___ _______ ______ ________ _____.
________ __________ ___ ______ _____ ____ __________ ______ ____.
___ ________ _______ ___ _____ ____.
________ ________ ______ ____ _______ ______ _____ ___ _______ _____ _________ ______.
________ __________ __________ ______ _______.
__________ ____ ____ ___ __________ ___ ___ ______ ______ _____ _____ ___.
____ ________ _________ _______ _________ ____ ______ __________ ________ ____ ____ ______.
______ ____ _______ _________ ______.
___ _________ __________ _________ _______ _________ ____ ________ ________.
______ ____ ______ ______ ______ ________ ____.
_______ ________ __________ ______ _________ _______.
______ ____ ___ ________ ________ __________ _______ ________ _______ ____ __________ _____.
___ _________ ___ ____ ____ _________ ________ ___ ____ ____ __________ ______.
________ _____ _______ _________ ________.
________ _________ __________ _____ __________ __________ ________ ____ _______.
__________ _________ ___ _____ _____ ____ _______ ________ _________.
________ ______ __________ ________ ______ _____ _______.
_________ ________ _____ ____ ____ _________ ________ _____ _____.
______ ________ ________ ____ _________ _____.
__________ ________ __________ _________ _________.
__________ _________ _______ ___ _____ ________ ____ _____ ____ _______.
________ ___ _______ __________ _______ ______ ________ _______ _______ ___ _________.
____ _________ _______ __________ ______ __________ _____ ______ _____ __________.
________ _________ ______ _______ ________ _____.
___ _______ ____ ________ _________ __________ ____.
_________ _________ _____ _______ ________.
___ ___ _____ ____ ____ ____ ______ _______ _______.
_________ ____ ____ ________ ______ _____ ____.
__________ _________ ________ ___ ______ ___ __________ ___ ___.
________ ___ __________ ____ _____ ____ _____ __________ ___ _____ _______ ______.
_________ ________ ___ ______ _______ ___.
________ _____ _____ ____ ________ _______ ___ ________ ____ _________ _______.
________ _________ _________ __________ ______ ____.
_____ _____ _______ ______ ____.
__________ ________ ____ _______ ___ _____ ________ __________ _________.
_____ ________ ___ __________ ________ _____ __________ _______ ______.
____ ______ __________ _________ ______ __________ _________.
_________ ________ ________ ___ ________ _________ __________ ____.
____ ________ ___ _____ _____ _________.
___ ____ ________ ______ _______ ________ _________ ______.
_________ _____ ________ ______ __________ ______ ___ ________ _________ _______ _______.
_______ _________ ____ ____ _________ ________.
_________ _____ _________ _____ ____ ____ __________ _______ _______.
___ __________ _____ __________ ____ _______ ____.
_________ ____ ___ ________ ________ ______ __________ ________ ________ ____ ______ _____.
_______ ________ _________ ______ __________ ___ _________ ___ ________ _______.
_____ ______ ____ __________ ______ ___ _______ ____.
____ ____ __________ ______ _________ _________.
_____ ___ _________ _________ _____.
____ ____ _______ _______ ___ _____.
_________ __________ _____ _____ ______ _________ _________.
________ ___.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance Write a menu driven program (using switch-case) which accepts a number
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→