Hey im sirtom93 and im learning c++
Moderator: Coders of Rage
My friend and i were searching dreamcast homebrew games when we came accros this. That code does actualy work. I compile and it plays through fine..... If you want i could upload the .exe
Im 14 years of age. I have 2 years to do whatever i want so why not do c++,my cousin is a master at it and has a computing technology degree. He gave me the books.
Im 14 years of age. I have 2 years to do whatever i want so why not do c++,my cousin is a master at it and has a computing technology degree. He gave me the books.
-
- 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:
Ok,here it is again.
Code: Select all
// 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);
}
Code: Select all
//Newrounds quiz by sirtom93.
#include <iostream>
#include <string>
using namespace std;
int main (){
string creator;
int score=0;
cout<<"Hello and welcome to the newgrounds quiz v1.0.\nYou can testyour knowledge on how well you know newgrounds! ";
cout<<"\n";
//Questions start here.
cout<<"question one: who is the creator of newgrounds";
cin>>creator;
//if and else loops statements.
if (creator=="TomFulp" ||creator=="tomFulp" || creator=="Tomfulp"){
cout<<"that is correct\n";
score+1;
}
else{
cout<<"that is incorrect \n\n";
cout<<"Your final score is"<<score"\n";
}
system ("PAUSE");
return (0);
}
That's kewl--It's good to see you applying your knowledge and making something that's not right out of the book.
I haven't actually had time to look through the code--But does it work this far? If so, great job.
One thing that I did notice as I was scrolling through...Your braces are indented off. That's fine, it takes a while to learn good style, but try your best to keep it all lined up. See, this:
should be
so that the end brace is lined up with the if statement.
Again, it's not an error or anything, but it prevents confusion and is good practice. Our Perl programmer for our game right now has complete shit style too, don't feel too bad. =P
I haven't actually had time to look through the code--But does it work this far? If so, great job.
One thing that I did notice as I was scrolling through...Your braces are indented off. That's fine, it takes a while to learn good style, but try your best to keep it all lined up. See, this:
Code: Select all
if (creator=="TomFulp" ||creator=="tomFulp" || creator=="Tomfulp"){
cout<<"that is correct\n";
score+1;
}
else{
Code: Select all
if (creator=="TomFulp" ||creator=="tomFulp" || creator=="Tomfulp"){
cout<<"that is correct\n";
score+1;
}
else{
Again, it's not an error or anything, but it prevents confusion and is good practice. Our Perl programmer for our game right now has complete shit style too, don't feel too bad. =P
- 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:
Im thinking of having a loop that goes back to the start if the user so desires. something like...
is that the best way of doing so?
Code: Select all
char y/n = y
while (y/n ="n"){
// code
cout<<"do you wish to continue: ";
cin>> y/n;
}
- 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:
-
- 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:
Yes. And while on the subject of that code snippet you can't have / in a variable name, that's division. You also can't compare strings with == (at least not C strings) like you're trying to. You can compare chars like that but "n" in this case is a null terminated string. To treat it as a char you do 'n' instead. Same applies to when you initialize your variable.
Got you. You may not see me round here that much as im going to to all out learning c++ over christmas and the internet distracts me.Tvspelsfreak wrote:Yes. And while on the subject of that code snippet you can't have / in a variable name, that's division. You also can't compare strings with == (at least not C strings) like you're trying to. You can compare chars like that but "n" in this case is a null terminated string. To treat it as a char you do 'n' instead. Same applies to when you initialize your variable.
^^^^^^^^^^^Kleithap wrote:Just read all these post, and NO OFFENSE but: ROFL.
That's all, thank you very much.
If you're into C/C++ game programming, I'd recommend Sam's Teach Yourself C++ in 24 Hours as a C++ primer, and then Game Programming All-in-One, Third Edition to get you used to game code (and get you out of the console).
DISCLAIMER: I'm not trying to be rude with the following comment, so just hear me out.
The first game you posted, the one that took you a month? For most programmers who have a true chance in the field, such a program would've been their day 2 or 3 project, if even that late. You might want to reconsider this, for even with a ton of dedication, true game programming will require you to learn vast amounts of new things and to be able to apply them in a very short amount of time. I have no advice for how to do this, but you're going to have to learn faster if you are truly interested.
DISCLAIMER: I was not trying to be rude with the previous comment, so just heed what I said and consider it.
You guys ought to know me. WTB j00r physics h4x, kthx
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA