Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » General Discussions » General Discussion » I Learn Some Basic C++!
Re: I Learn Some Basic C++! [message #392003 is a reply to message #391996] Tue, 23 June 2009 18:04 Go to previous messageGo to previous message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma:
General (4 Stars)
nopol10 wrote on Tue, 23 June 2009 17:00

SSnipe wrote on Wed, 24 June 2009 06:48

as i said im new and this basic stuff is all i know so far but im just guessing it but here cnc

#include "stdafx.h"
#include <iostream>
using namespace std;

int main() {
	double a, b, c, d, e;
	cout << "Enter numbers here to be added up (5 is the max) then multiplied by 100 ";
	    cin >> a;
	cout << "Enter second digits: ";
		cin >> b;
	cout << "Enter third digits: ";
		cin >> c;
	cout << "Enter fourth digits ";
		cin >> d;
	cout << "Enter fifth digits: ";
		cin >> e;
    cout << "The Output Is: " << 100 * a + b + c + d + e;
	return 0;
}




Order of operations, what happens here is that a is multiplied by 100 and then added together with b, c, d and e. What you need is to bracket up a+b+c+d+e.
cout << "The Output Is: " << 100 * (a + b + c + d + e);




OO so simple, so do you always got to put those variables in brackest when theres mroe then one? or always?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Your daily commute to work!
Next Topic: Virus
Goto Forum:
  


Current Time: Mon Nov 25 06:16:33 MST 2024

Total time taken to generate the page: 0.01304 seconds