0
I need help
//Write a program that receives a integer, positive three-digit number (number in the range 100-999 inclusive) by the following message #include <iostream> using namespace std; int main() { cout << "enter a three digit number:" << endl; int digit1,digit2,digit3,sum; int num; digit1 = (num%10), digit2 = (num/10%10), digit3 = (num/100), cout << "the sum is: "; sum = digit1 + digit2 + digit3 ; cout << "the sum is" << sum << endl ; return 0; }
1 Odpowiedź
+ 2
Add this line to read value for variable <num>:
cin >> num;
Before this line:
digit1 = (num % 10);
(Edit)
For the next time, please be more descriptive with your question. "I need help" didn't describe the problem clearly, other than being ineffective way to communicate.