Hey im sirtom93 and im learning c++
Moderator: Coders of Rage
Hey im sirtom93 and im learning c++
Ive been learning c++ for about a months now and the code im most pleased with that i did all my self is the squaring code.
#include <iostream>
using namespace std;
int main()
{
int number;
int sqaure;
cout << "enter a number : " ;
cin >> number;
cout << "the number you entered is " << number;
cout << "\n\n";
cout << "the square of this number is ";
sqaure = number * number;
cout << sqaure;
cout << "\n\n";
system ("PAUSE");
return 0;
}
So im learning and i think ill try some opengl next.
#include <iostream>
using namespace std;
int main()
{
int number;
int sqaure;
cout << "enter a number : " ;
cin >> number;
cout << "the number you entered is " << number;
cout << "\n\n";
cout << "the square of this number is ";
sqaure = number * number;
cout << sqaure;
cout << "\n\n";
system ("PAUSE");
return 0;
}
So im learning and i think ill try some opengl next.
-
- Chaos Rift Junior
- Posts: 272
- Joined: Wed Sep 29, 2004 5:53 pm
- Favorite Gaming Platforms: NES, SNES
- Programming Language of Choice: C/C++
- Location: Umeå, Sweden
- Contact:
I understand what your saying. What do you recomend i go onto then?Tvspelsfreak wrote:How much do you know about control blocks, functions, structures, classes and such? Not that I wanna discourage you or something but squaring a number is far from doing something in OpenGL.
The fact is im quite pleased with what ive learnt and fully understand in just one month.
-
- Chaos Rift Junior
- Posts: 272
- Joined: Wed Sep 29, 2004 5:53 pm
- Favorite Gaming Platforms: NES, SNES
- Programming Language of Choice: C/C++
- Location: Umeå, Sweden
- Contact:
- JS Lemming
- Game Developer
- Posts: 2383
- Joined: Fri May 21, 2004 4:09 pm
- Location: C:\CON\CON
I'm not trying to be mean or anything... but this is the first thing I thought of when you said you were going to try OpenGL next.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
- JS Lemming
- Game Developer
- Posts: 2383
- Joined: Fri May 21, 2004 4:09 pm
- Location: C:\CON\CON
Here it is. My first ever game in c++. Higher and Lower.
// higher lower game by sirtom93.
#include <time>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int guess;
int answer= rand() %10+1;
cout<< "welcome to the higher or lower game, by Sirtom93";
cout<< "\n";
cout<< "Please enter a number between 1 and 10: ";
cin>> guess;
cout<<"\n\n";
while ((guess>answer)||(guess<answer>answer){
cout <<"the number is to big,please try again";
cin >> guess;
}
if (guess<answer){
cout <<"the number is to small,please try again";
cin>> guess;
}
}
if (guess=answer);
cout<<"well done,you guessed right!";
cout<< "\n\n\n";
system ("PAUSE");
return (0);
}
// higher lower game by sirtom93.
#include <time>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int guess;
int answer= rand() %10+1;
cout<< "welcome to the higher or lower game, by Sirtom93";
cout<< "\n";
cout<< "Please enter a number between 1 and 10: ";
cin>> guess;
cout<<"\n\n";
while ((guess>answer)||(guess<answer>answer){
cout <<"the number is to big,please try again";
cin >> guess;
}
if (guess<answer){
cout <<"the number is to small,please try again";
cin>> guess;
}
}
if (guess=answer);
cout<<"well done,you guessed right!";
cout<< "\n\n\n";
system ("PAUSE");
return (0);
}
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
It doesn't work. There's no way that you even tried to compile this.
That's wrong. Not only did you forget a parenthesis, but your logic is also off. Your while loop is also screwed, because it's not nesting the other ifs. The program flow doesn't work anything like you'd assume it would. Again, I recommend actually trying to run it, first.
You're setting guess equal to answer, not checking equality.
Code: Select all
while ((guess>answer)||(guess<answer>answer)
Code: Select all
if (guess=answer);
Um. Listen to your logic. Is one EVER greater than one? Is three EVERY greater than three? Is ANY number EVER greater than that same number? The answer to each of these is NO--And yes, that's exactly what you told the program to check for in your gnarled excuse of a while{}.
My advice to you is to avoid trying to memorize programs from the book you got (you say C++ superbible?) and actually learn to understand the logic behind it instead. Stop trying to recall a program from memory--Try tweaking them to do what you want, which requires you to understand it, and the rest should come naturally.
Btw, how old are you? C++ might actually be above your head a bit (judging by some of the posts you've made) so perhaps maybe you should start programming with something else? If your intent is games, perhaps try BlitzPlus (which I personally used for most of my 1st games)? Or Visual Basic?
Just suggestions. And out of curiosity, how'd you reach these forums? Was it from the development movies?
My advice to you is to avoid trying to memorize programs from the book you got (you say C++ superbible?) and actually learn to understand the logic behind it instead. Stop trying to recall a program from memory--Try tweaking them to do what you want, which requires you to understand it, and the rest should come naturally.
Btw, how old are you? C++ might actually be above your head a bit (judging by some of the posts you've made) so perhaps maybe you should start programming with something else? If your intent is games, perhaps try BlitzPlus (which I personally used for most of my 1st games)? Or Visual Basic?
Just suggestions. And out of curiosity, how'd you reach these forums? Was it from the development movies?
-
- Chaos Rift Junior
- Posts: 272
- Joined: Wed Sep 29, 2004 5:53 pm
- Favorite Gaming Platforms: NES, SNES
- Programming Language of Choice: C/C++
- Location: Umeå, Sweden
- Contact:
That program doesn't even compile.
What (guess<answer>answer) does is it performs the first comparison which has a boolean result (true/false, 0/1). That value is then used in the second comparison.
Not only is this wrong but it's totally unneccessary when you get the rest of the program working.
What (guess<answer>answer) does is it performs the first comparison which has a boolean result (true/false, 0/1). That value is then used in the second comparison.
Code: Select all
if (guess=answer);
Hey, Sirtom93, I apologize if we all come off as asses. I guess most of us think of you as the guy in way above his head--No offense.
Your first post when you said
I'm sure most everybody here, who've been programming for years, laughed their asses off when they read that. Yes, it's very good that you're trying to learn. Just a bit of advice: Please, don't post like an idiot. It's more than obvious that you haven't got the slightest clue what OpenGL is, and until you do, please don't speak of it so lightly. "Yeah, I'm going to learn that next" makes you sound stupid. Also, perhaps proofreading your posts before submitting them would help prevent you from coming off as a little kid. Seriously.
I'd be more than willing to help you learn. We all would. Just stop acting like a little kid using mommas's computer.
Good job with your last program...But if you go and look back at your book that you probably copied it from, you did it wrong. Try compiling it, it's not going to work. If you need help figuring out why it doesn't work, (after reading all the other posts of the forum member pointing out the mistakes) feel free to ask.
Good luck.
Your first post when you said
made you sound like a complete idiot, to be completely honest. That is like saying "Yeah, so I just learned how to add two numbers together--I think now I'm ready to learn Calculus," except, without proper capitalization or punctuation.So im learning and i think ill try some opengl next.
I'm sure most everybody here, who've been programming for years, laughed their asses off when they read that. Yes, it's very good that you're trying to learn. Just a bit of advice: Please, don't post like an idiot. It's more than obvious that you haven't got the slightest clue what OpenGL is, and until you do, please don't speak of it so lightly. "Yeah, I'm going to learn that next" makes you sound stupid. Also, perhaps proofreading your posts before submitting them would help prevent you from coming off as a little kid. Seriously.
I'd be more than willing to help you learn. We all would. Just stop acting like a little kid using mommas's computer.
Good job with your last program...But if you go and look back at your book that you probably copied it from, you did it wrong. Try compiling it, it's not going to work. If you need help figuring out why it doesn't work, (after reading all the other posts of the forum member pointing out the mistakes) feel free to ask.
Good luck.