#include #include void msquare(int x); void rnum(int x); int lcm(int valx,int valy); void main(void) { char choice; int x,y; cout << " [M] Magic Squares "<< " \n"; cout << " [R] Reverse Numbers " << " \n"; cout << " [L] Least Common Multiples " << " \n"; cout << " [Q] Quit " << " \n\n"; cout << "Please enter your choice --> "; cin >> choice; switch (choice) { case 'M': case 'm': cout << " How many magic squares do you want --> "; cin >> x; msquare(x); break; case 'R': case 'r': cout << " Please enter a number to reverse --> "; cin >> x; break; case 'L': case 'l': cout << " Enter the smaller value of the two --> " << " \n"; cin >> x; cout << " Enter the greater value of the two --> " << " \n"; cin >> y; cout << " The least common multiple is " << lcm(x,y) << " \n"; break; case 'Q': case 'q': break; default: cout << "Invalid Choice.\n"; break; } } void msquare(int x) { int z = 4,found = 0,count = 0,ourint = 2; while(found < x) { long square = pow(ourint,2.0); long total = 0; for (int g = 1; g < square;g++) { total += g; } if (total == square) { cout << "Magic square " << found << " : " << ourint; found++; } ourint++; } } void rnum(int x) { int num = 0, b = 5; cout << "Reversed Number is : "; while(b > 0) { cout << x % (10 * b); b--; } } int lcm(int x,int y) { int lcmnum = 0; int c = 1; while (lcmnum <= 0) { if (c % x <= 0 && c % y <= 0) { lcmnum = c; } c++; } return lcmnum; }