How do you use char instead of unsigned to calculate numbers?
This is using char only and nothing else.
Step 1: I ask the user to enter a number. Step 2: User enters a number. Step 3: Number user entered is going to be that number squared or cubed or w/e.
For example;
"Enter a number: " 3
" Number you entered multiplied four times: "81 (Since (3)*(3)*(3)*(3) = 81)
Another example;
"Enter a number: " 5
" Number you entered multiplied four times: "625 (Since (5)*(5)*(5)*(5) = 625)
Code:
1 2 3 4
Char num;
cout << "Enter a number";
cin >> num;
cout << "Number you entered multiplied four times: " << (num)*(num)*(num)*(num) << endl;
What do you mean? I'm not really certain as to what your question is exactly. You can treat characters as numbers like you are, but they are only one byte so they can't contain very much.
#include <iostream>
int main()
{
char num;
int tmp;
std::cout << "Enter a number: ";
std::cin >> tmp;
num = tmp;
std::cout << "num * num * num * num == " << num * num * num * num << std::endl;
}