0% found this document useful (0 votes)
20 views5 pages

Include

Uploaded by

atta32059
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Include

Uploaded by

atta32059
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include<iostream>

using namespace std;


int main() {
cout << "StudentID = BC230410520" << endl;
cout << "StudentName = Eshah" << endl;
cout << "Welcome to the main menu" << endl;
int choice;

do {
cout << "Hello " << "Eshah " << ",StudentId=" << "BC230410520" <<
",Welcomme to the main menu" << endl;
cout << "1. Addition" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cout << "5. Exist" << endl;
cout << "Enter your choice: ";
cin >> choice;
int num;
float result;
switch(choice) {
case 1 : {
cout << "How many numbers do you want to add? ";
cin >> num;
result = 0;
for(int i = 0; i < num; ++i) {
float temp;
cout << "Enter numbers " << i + 1 << ": ";
cin >> temp;
result += temp;
}
cout << "Result of addition: " << result << endl;
break;
}
case 2 : {
cout << "How many numbers do you want to subtract? ";
cin >> num;
cout << "Enter number 1: ";
cin >> result;
for(int i = 0; i < num; ++i) {
float temp;
cout << "Enter number " << i + 1 << ": ";
cin >> temp;
result -= temp;
}
cout << "Result of subtraction: " << result << endl;
break;
}
case 3 : {
cout << "How many numbers do to want to multiply? ";
cin >> num;
result = 1;
for(int i = 0; i < num; ++i) {
float temp;
cout << "Enter number " << i + 1 << ": ";
cin >> temp;
result *= temp;
}
cout << "Result of multiplication: " << result << endl;
break;
}
case 4 : {
cout << "How many numbers do tou want to divide? ";
cin >> num;
cout << "Enter number 1: ";
cin >> result;
for(int i = 0; i < num; ++i) {
float temp;
cout << "Enter number " << i + 1 << ": ";
cin >> temp;
if(temp == 0) {
cout << "Error! Division by zero is impossible. Please
divide it by a non-zero divisor. " << endl;
break;
}
result /= temp;
}
cout << "Result of division: " << result <<endl;
break;
}
case 5 : {
cout << "Exist program. " << endl;
break;
}
default: {
cout << "Invalid choice! Please enter a number between 1 and 5.
" << endl;
break;
}
}
if(choice != 5) {
cout << "Do you want to continue (y/n)? ";
cin >> choice;
}
}while(choice == 'y' || choice == 'Y');
return 0;
}

You might also like