|
-
September 29th, 2009, 12:11 AM
#1
Reversing a Number
Hi,
I'm trying to create a program that takes two numbers, finds their average showing decimals, and then finds the reverse value of the first 4 non-decimal digits of the average. I'm writing the program in Emacs on a Linux machine.
When I try to compile my code in G++, I get an error. Where am I going wrong? I can't figure out how to debug using keyboard commands in Emacs, so I'm not 100% sure where the problem is.
#include <iostream>
using namespace std;
int main ()
{
int num1;
int num2;
int num3;
cout << "Please enter two positive integers with at most four digits each: ";
cin >> num1 >> num2; // User inputs numbers here
cout << "Their average is " << num3 = (num1 * num2) / 2.0; // Shows the average with decimal places
int mod1;
int rev1;
rev1 = 0
{
mod1 = num3 % 1000; // Show the reverse average to 4 digits?
num3 = num3 / 1000;
rev1 = (rev1 * 1000) + mod1;
}
cout << "The average reversed is " << rev1;
}
Last edited by AllYourBase; September 29th, 2009 at 09:18 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|