You are on page 1of 1

1.

#include <iostream>
using namespace std;
int calculator(int m, int n, char operand)
{
int sum = 0, diff = 0 , prod = 0, divi = 0;
if (operand == char(43))
{
sum = m + n;
return sum;
}
else if (operand == char(45))
{
diff = m - n;
return diff;
}
else if (operand == char(42))
{
prod = m * n;
return prod;
}
else if (operand == char(47))
{
divi = m / n;
return divi;
}
}
int main() {
int m, n;
char operand;
cout << "Enter the first number: ";
cin >> m;
cout << "Enter the second number: ";
cin >> n;
cout << "Enter the operand: ";
cin >> operand;
cout << calculator(m, n, operand);
}
2.
#include <iostream>
#include <ctime>
using namespace std;
void display()
{
int a[10][10];
srand(time(0));
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
a[i][j] = rand() % 44 + 7;
cout << a[i][j];
}
cout << endl;
}
}
int main() {
display();
}
3.

You might also like