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 #392062 is a reply to message #392003] Wed, 24 June 2009 10:00 Go to previous messageGo to previous message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma:
General (3 Stars)
SSnipe wrote on Wed, 24 June 2009 02:04

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 up on BODMAS (or BADMAS).
 
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: Wed Jan 08 03:37:34 MST 2025

Total time taken to generate the page: 0.01396 seconds