Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » General Discussions » General Discussion » I Learn Some Basic C++!
I Learn Some Basic C++! [message #391886] Tue, 23 June 2009 01:01 Go to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
Lol this is very very very simple stuff to you guys but after reading on in my c++ book (c++ without fear referred to me by reborn) I made a simple console command prompt that what ever number you type in gets multiply by 100! lol nothing special but im happy im learning something

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

int main() {
	double x;
	cout << "Enter Number Here To Be Multiplied By 100: ";
	cin >> x;
    cout << "The Output Is: " << 100 * x;
	return 0;
}
Re: I Learn Some Basic C++! [message #391929 is a reply to message #391886] Tue, 23 June 2009 07:46 Go to previous messageGo to next message
Nightma12 is currently offline  Nightma12
Messages: 2593
Registered: August 2003
Karma: 0
General (2 Stars)
Category Moderator
good for you. Sarcasm Thumbs Up
Re: I Learn Some Basic C++! [message #391937 is a reply to message #391886] Tue, 23 June 2009 08:30 Go to previous messageGo to next message
ErroR is currently offline  ErroR
Messages: 2984
Registered: March 2008
Location: Moldova
Karma: 0
General (2 Stars)
why the sarcasm Dont Get It it's nice of him learning Smile
Re: I Learn Some Basic C++! [message #391943 is a reply to message #391886] Tue, 23 June 2009 09:12 Go to previous messageGo to next message
cnc95fan is currently offline  cnc95fan
Messages: 1261
Registered: July 2007
Karma: 0
General (1 Star)
Now do something where I can enter in a specified amount of numbers, it adds up all those numbers and then gets multiplied by 100
Re: I Learn Some Basic C++! [message #391948 is a reply to message #391886] Tue, 23 June 2009 09:43 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
http://www.emblibrary.com/EL/product_images/C4749r.jpg

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: I Learn Some Basic C++! [message #391960 is a reply to message #391886] Tue, 23 June 2009 12:00 Go to previous messageGo to next message
archerman is currently offline  archerman
Messages: 348
Registered: May 2007
Location: Istanbul / Turkey
Karma: 0
Recruit
this would be the perfect fit for you Wink

http://rlv.zcache.com/c_programming_tshirt-p235905337691303285cpu4_400.jpg


sorry for my English

http://img7.imageshack.us/img7/117/userbar730595.gif
Re: I Learn Some Basic C++! [message #391964 is a reply to message #391886] Tue, 23 June 2009 12:39 Go to previous messageGo to next message
raven
Messages: 595
Registered: January 2007
Location: Toronto, Ontario
Karma: 0
Colonel
printf + scanf > cin + cout

-Jelly Administrator
-Exodus Administrator

[Updated on: Tue, 23 June 2009 12:40]

Report message to a moderator

Re: I Learn Some Basic C++! [message #391965 is a reply to message #391886] Tue, 23 June 2009 12:45 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
Evolve it...

Allow people to input a multiplier (currently your multiplier is 100).
So they input x as the number they want to multiply, then y as the multiplier.
You then have a program that can times any two numbers and give you the answer.
Further on in that book just a little your learn to create your own functions and use different libraries for triangular numbers...

Nice one dude, way to go! Smile



Re: I Learn Some Basic C++! [message #391966 is a reply to message #391943] Tue, 23 June 2009 12:59 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
cnc95fan wrote on Tue, 23 June 2009 09:12

Now do something where I can enter in a specified amount of numbers, it adds up all those numbers and then gets multiplied by 100

I just tryed that, odd enought I can get them to all add up..and even plus another number, but wont multiply correctly for some reason
Re: I Learn Some Basic C++! [message #391971 is a reply to message #391886] Tue, 23 June 2009 13:32 Go to previous messageGo to next message
cnc95fan is currently offline  cnc95fan
Messages: 1261
Registered: July 2007
Karma: 0
General (1 Star)
Post the code and ask for help Satisfied
Re: I Learn Some Basic C++! [message #391988 is a reply to message #391886] Tue, 23 June 2009 15:48 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
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;
}

Re: I Learn Some Basic C++! [message #391994 is a reply to message #391964] Tue, 23 June 2009 16:47 Go to previous messageGo to next message
Sir Kane
Messages: 1701
Registered: March 2003
Location: Angerville
Karma: 0
General (1 Star)
raven wrote on Tue, 23 June 2009 14:39


Quote:

Quote:

Quote:

Quote:

printf + scanf > cin + cout








Proud N9500 and proud N6270 user. Creator of the IEE libraries (original bhs.dll) and the RB series software.
http://n00bstories.com/image.fetch.php?id=1189992501http://www.n00bstories.com/image.fetch.php?id=1257492907
Re: I Learn Some Basic C++! [message #391996 is a reply to message #391988] Tue, 23 June 2009 17:00 Go to previous messageGo to next message
nopol10 is currently offline  nopol10
Messages: 1043
Registered: February 2005
Location: Singapore
Karma: 0
General (1 Star)
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);




nopol10=Nopol=nopol(GSA)

http://i14.photobucket.com/albums/a330/napalmic/siggy.jpg
Re: I Learn Some Basic C++! [message #391998 is a reply to message #391886] Tue, 23 June 2009 17:01 Go to previous messageGo to next message
cnc95fan is currently offline  cnc95fan
Messages: 1261
Registered: July 2007
Karma: 0
General (1 Star)
Nvm

[Updated on: Tue, 23 June 2009 17:02]

Report message to a moderator

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 next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
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?
Re: I Learn Some Basic C++! [message #392004 is a reply to message #391886] Tue, 23 June 2009 18:06 Go to previous messageGo to next message
raven
Messages: 595
Registered: January 2007
Location: Toronto, Ontario
Karma: 0
Colonel
It's not just that there's multiple variables. It's that you have to follow the order of operations when doing any mathematical calculation, and brackets are part of said order of operations

BEDMAS - Brackets/Exponents/Division/Multiplication/Addition/Subtraction


-Jelly Administrator
-Exodus Administrator
Re: I Learn Some Basic C++! [message #392008 is a reply to message #392004] Tue, 23 June 2009 18:27 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
raven wrote on Tue, 23 June 2009 18:06

It's not just that there's multiple variables. It's that you have to follow the order of operations when doing any mathematical calculation, and brackets are part of said order of operations

BEDMAS - Brackets/Exponents/Division/Multiplication/Addition/Subtraction

ok that makes since thanks for that tip
Re: I Learn Some Basic C++! [message #392031 is a reply to message #392003] Wed, 24 June 2009 00:51 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
SSnipe wrote on Wed, 24 June 2009 03: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?

I Would also suggest to make a loop instead of using 5 doubles.
Something like this:
#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
     double n, t; //n = number filled in, t = total counter
     cout << "Please enter 5 numbers seperated by a space";

     for(int i=0; i<5; i++) //To increase the number of numbers you can fill in you just have to replace the 5 to another number so you dont have to copy/paste again for every new number
     {
     cin >> n;
     t =+ n;
     }

     cout << "The output is: " << 100*t;
     return 0;
}


EDIT: Havent tested it but wrote it out of my mind but you'll get the idea right???


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Wed, 24 June 2009 00:53]

Report message to a moderator

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 next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
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).
Re: I Learn Some Basic C++! [message #392127 is a reply to message #392062] Wed, 24 June 2009 18:23 Go to previous messageGo to next message
YazooGang is currently offline  YazooGang
Messages: 742
Registered: August 2008
Location: US
Karma: 0
Colonel
BUG, BUG, BUG!
Ok, i tried it out and when i need to get the answer, the window closes. I fixed it but fix it your own for your learning. lol
Re: I Learn Some Basic C++! [message #392129 is a reply to message #392127] Wed, 24 June 2009 18:37 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
YazooGang wrote on Wed, 24 June 2009 18:23

BUG, BUG, BUG!
Ok, i tried it out and when i need to get the answer, the window closes. I fixed it but fix it your own for your learning. lol

Lol, ya I know it runs when you do ctrl+F5 in visual c++ but when you click and run program in folder...closes
Re: I Learn Some Basic C++! [message #392156 is a reply to message #391886] Wed, 24 June 2009 21:52 Go to previous messageGo to next message
dr3w2 is currently offline  dr3w2
Messages: 485
Registered: September 2006
Location: Ottawa,Canada
Karma: 0
Commander
erm BEDMAS?

Brackets
Exponents
Division
Multiplication
Addition
Subtraction


top to bottom, that's like grade 9 math ...

All languages follow this.. just like your calculator

5*5+2 = 27
5*(5+2) = 35



n00bstories Server Administrator

[Updated on: Wed, 24 June 2009 21:56]

Report message to a moderator

Re: I Learn Some Basic C++! [message #392157 is a reply to message #392156] Wed, 24 June 2009 22:14 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
andr3w282 wrote on Wed, 24 June 2009 21:52

erm BEDMAS?

Brackets
Exponents
Division
Multiplication
Addition
Subtraction


top to bottom, that's like grade 9 math ...

All languages follow this.. just like your calculator

5*5+2 = 27
5*(5+2) = 35



How would i write thme out in c++? as in how do i knwo which go in abckets and which can i place next to each other?
for example

4 * x (1 + 2) lets pretend thios si teh rite way to write it
how would i know that?a and end up like

1 + 2 (4 * x0 or something..its hard for me to explain

or maybe even

10 * x + 5

[Updated on: Wed, 24 June 2009 22:16]

Report message to a moderator

Re: I Learn Some Basic C++! [message #392159 is a reply to message #392157] Wed, 24 June 2009 23:35 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)

andr3w282 wrote on Wed, 24 June 2009 21:52

erm BEDMAS?


BODMAS where I come from Razz

SSnipe wrote on Thu, 25 June 2009 06:14


4 * x (1 + 2)


int x = 10;
cout << 4 * x * (1 + 2) << endl; //120


SSnipe wrote on Thu, 25 June 2009 06:14


1 + 2 (4 * x0


int x = 10;
cout << 1 + 2 * (4 * x * 0) << endl; //1 


SSnipe wrote on Thu, 25 June 2009 06:14


10 * x + 5


int x = 10;
cout << 10 * x + 5 << endl; //105
Re: I Learn Some Basic C++! [message #392270 is a reply to message #391886] Thu, 25 June 2009 14:19 Go to previous messageGo to previous message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
What I mean is how do you know there to put the variable, and then the other numbers, and which ones go inside ther brackets
Previous Topic: Your daily commute to work!
Next Topic: Virus
Goto Forum:
  


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

Total time taken to generate the page: 0.01316 seconds