| View previous topic :: View next topic |
| Author |
Message |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Tue Jan 22, 2008 6:05 pm Post subject: *Proud* |
|
|
I'm so proud of myself . I made first workign program in C++ LOL.
I coded the thing all on my own the only thing i give credits to is
Cx for cin.get and cin.ignore., other than that i did all by myself
*play im a big boy know song* LOL, k so. ill post the .exe with source if anyone wants. (10-15 lines of code but w/e )
here ya go!
-... can't post the exe or the source file.... ill just copy paste code....
| Code: |
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int num1, num2, num3;
cout << "Enter your first number" << endl;
cin >> num1;
cout << "Enter your second number" << endl;
cin >> num2;
cout << "Enter your third number" << endl;
cin >> num3;
cout << num1 << "+" << num2 << "+" << num3 << "=" << num1+num2+num3 << endl;
cin.ignore();
cin.get();
return 0;
}
|
*is dissapointed *
|
|
| Back to top |
|
 |
.Murder. Grandmaster Cheater
Reputation: 0
Joined: 28 Nov 2007 Posts: 723
|
Posted: Tue Jan 22, 2008 6:11 pm Post subject: |
|
|
Cute =P
_________________
|
|
| Back to top |
|
 |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Tue Jan 22, 2008 6:16 pm Post subject: |
|
|
| im trying to make it so that you can enter 3 numbers and then have it devide by 3 to find the average, but the math is off... do you know if the command for division is "/" ?
|
|
| Back to top |
|
 |
onfia Cheater
Reputation: 0
Joined: 18 Jan 2008 Posts: 45
|
Posted: Tue Jan 22, 2008 6:20 pm Post subject: |
|
|
| / or \ but i think they do different types of division i cant remember.[/b]
|
|
| Back to top |
|
 |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Tue Jan 22, 2008 6:24 pm Post subject: |
|
|
this is my modified code from what i added in the start of the thread
| Code: |
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int num1, num2, num3, num4;
num4 = 3;
cout << "Enter your first number" << endl;
cin >> num1;
cout << "Enter your second number" << endl;
cin >> num2;
cout << "Enter your third number" << endl;
cin >> num3;
cout << "The average of your numbers" << "=" << num1+num2+num3/num4 << endl;
cin.ignore();
cin.get();
return 0;
}
|
i use / and the math ends up all wrong...
example: i enter 5,5,5 for my number which = 15 and then it should divide (/) by num4= 3 and 15/3 = 5. it gets 11 ...
|
|
| Back to top |
|
 |
killersamurai Expert Cheater
Reputation: 0
Joined: 10 Sep 2007 Posts: 197 Location: Colorado
|
Posted: Tue Jan 22, 2008 6:27 pm Post subject: |
|
|
/ = divide
% = modulus (remainder)
Order of operations
(a+b+c) / d
It will add first then divide
Last edited by killersamurai on Tue Jan 22, 2008 6:28 pm; edited 1 time in total |
|
| Back to top |
|
 |
onfia Cheater
Reputation: 0
Joined: 18 Jan 2008 Posts: 45
|
Posted: Tue Jan 22, 2008 6:27 pm Post subject: |
|
|
Try using Parenthesis on the math. Remember the Order of Operations. Adding comes last, so division and multiply come first.
Whatever is in the parenthesis in math, the compiler does first, stores it somewhere, and uses it to add whatever number you requested.
|
|
| Back to top |
|
 |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Tue Jan 22, 2008 6:29 pm Post subject: |
|
|
| Code: |
num1+num2+num3/num4
|
will this know to add numbs 1-3 then divide by num4, or do i have to put like a pause, then tell to divide.
|
|
| Back to top |
|
 |
wunder312355 Grandmaster Cheater
Reputation: -1
Joined: 14 May 2007 Posts: 568
|
Posted: Tue Jan 22, 2008 6:30 pm Post subject: |
|
|
(num1+num2+num3) / num4
so basicly
First perform any calculations inside parentheses.
Next perform all multiplications and divisions, working from left to right.
Lastly, perform all additions and subtractions, working from left to right.
|
|
| Back to top |
|
 |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Tue Jan 22, 2008 6:34 pm Post subject: |
|
|
| thefun25 wrote: | (num1+num2+num3) / num4
so basicly
First perform any calculations inside parentheses.
Next perform all multiplications and divisions, working from left to right.
Lastly, perform all additions and subtractions, working from left to right. |
thanks xD it was probably think 1/4 of the num3.
IT WORKED!
Last edited by MegaForum on Wed Jan 23, 2008 1:36 pm; edited 1 time in total |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Tue Jan 22, 2008 9:43 pm Post subject: |
|
|
Jacob, maybe next time, you should blur out your name.
_________________
|
|
| Back to top |
|
 |
MegaForum Grandmaster Cheater
Reputation: 0
Joined: 20 Aug 2007 Posts: 558
|
Posted: Wed Jan 23, 2008 1:36 pm Post subject: |
|
|
| samuri25404 wrote: | | Jacob, maybe next time, you should blur out your name. |
>.<
|
|
| Back to top |
|
 |
|