Data Structure & Algorithm
Data Structure & Algorithm
Data Structure & Algorithm
#include <cmath>
#include <cstdlib>
// Function declarations
void calculator();
void pattern();
void intro();
// Global variables
int b, c;
char opp;
int main() {
intro();
int num;
do {
c = 1;
case 1:
calculator();
break;
case 2:
pattern();
break;
default:
cout << "Incorrect Choice. Please try again from 1 and 2.\n";
} while (c == 1);
return 0;
void calculator() {
do {
if (opp == '^') {
} else {
cout << "Enter the Second Number: ";
switch (opp) {
case '+':
cout << fnum << " + " << snum << " = " << fnum + snum << "\n";
break;
case '-':
cout << fnum << " - " << snum << " = " << fnum - snum << "\n";
break;
case '*':
cout << fnum << " * " << snum << " = " << fnum * snum << "\n";
break;
case '/':
if (snum != 0) {
cout << fnum << " / " << snum << " = " << fnum / snum << "\n";
} else {
break;
case '^':
cout << fnum << " ^ " << snum << " = " << pow(fnum, snum) << "\n";
break;
default:
cout << "Incorrect Operator Entry. Please choose from +, -, *, /, and ^.\n";
}
cout << "\n";
cin >> c;
} while (c == 2);
void pattern() {
do {
cin >> b;
switch (b) {
case 1:
break;
case 2:
break;
default:
cout << "Wrong Pattern Number Entry.\n";
} while (c == 2);
void intro() {
do {
system("cls");
system("cls");
break;
} else {
system("pause");
} while (true);
}