Programming info and exercises

Started by
7 comments, last by nuclearfission 15 years, 4 months ago
Hi to all. I was just started learning C++ and I am finding it a little harder than I thought. I don't know what to start with, things to make that is, also I am finding it hard to find any large amount of good information to kick start me off. The only thing that I can think of doing at the moment is to make a calc, but all I can do it the layout through the design. I am using Visual Studio 05 for now, but I will soon have 08. Would anyone be able to point me to some tutorials and some general infomation about programming please? Thanks in advance. Dextrous.
Advertisement
There are a lot of C++ primers that are really good out there. If your looking for a book the best book that I have read and really liked its way of introducing concepts of C++ was Problem Solving with C++ and anyone of the Frank M. Carrano books he is a really good author and his books are pretty clear as to whats going on. Hope that helps.
There are a couple of free C++ books at the bottom of this post. This site also has lots of excellent information.

You should also know that C++ is usually not recommended as a first language. Python or C# might be a better choice.
One of the best tutorials on the web are those you get if you whrite in google C++. Here is the link http://www.cplusplus.com/doc/tutorial/. I basic C++ through this and a book called Beginning C++ game programming ( I think it is like this). These two shud get you started.

For practice. Make anything you think you are capable off. I tried to do many experimental 15 - 30 minutes programms to exercise in something and to make something interesting.

Never give up:P
-----------------------------Please visit my GameDev Blog:http://red-dev.co.nr/
Thanks for the info, it is very useful and I'm looking forward to getting stuck into C++. Which is what I thought I had, turns out that I am using C# 05 atm, but C++ 08 is on the DL.

Thanks to all who posted.

Dextrous.
Well, the first thing that you are going to want to do is create a "Hello World" program. Basically, it executes and displays one line of text (Hello, World!) to the console. This is beneficial in that it teaches you the structure of the language (how to write a simple program) as well as one of the most basic elements of programming; outputting data to the output device.

Once that is working, modify it to ask for your name, then display "Hello, [Name]!" That would teach you how to accept input from the keyboard.

In essence, create something very basic and implement one functionality modification per change. Maybe next, have it pull the time from the system clock and display that as well.

With a little bit of luck, work, frustration, and browsing, you may be able to create a text based game of Rock-Paper-Scissors some day. Diligence and consistency; stick with it, don't give up, no matter how futile it may seem.

If C++ seems to be whooping your butt, then try learning C++ AND another higher level language at the same time. That's what I did, I did a lot of development in Visual Basic while I was learning C++. When you start envisioning in your head how to implement the things that seem so basic in VB, then you know that you're really learning something.

Also, the first thing that you need to do is learn how to make a console program, forget all that graphical stuff for now.
Thanks for the info sweetbread. I have been working through the exercises and examples that the help center has, but thats about all I have to go off atm, my GF just brought me a book - C++ for dummies - I hasn't had a good look through it yet but it looks good. Though I am finding the help center information not so helpful, also its a pain in the ass not having a fixed internet line.

Hopefully C++ should reach me soon and I can start working through my book, do you have any pointers for C# in the mean time??

Thanks for the help.

Dextrous.
A very good book for beginners is Beginning C++ Through game programming.

http://www.amazon.com/Beginning-Through-Game-Programming-Second/dp/1598633600/ref=sr_1_1?ie=UTF8&s=books&qid=1229780715&sr=1-1

It's a great book, buy it, learn everything inside and then get a more advanced one.
i've never seen C#, but i was thinking about learning it. Anyway i made this code for you, it might be a little advanced, but mabey you can read it and modify it, see how things work in it. You said you wanted to make a calc program, well i made one that only adds and subtracts, so you could possibly modify it to multiply and divide. Um there might comments in there that explain how to do something you probebly already know how to do, but here it is anyway. i ran it in VC++ 08.

// beginning of code ///////////////////////////////

//include the necessary files
#include <iostream>

//we don't have to use 'std' hurrah!
using namespace std;

//our class for the program
class calc
{
public:
//make our input integer, and other important stuff
int input;
int number;
bool running;

//ask funtion
void ask()
{
//print what you'd like to do
cout << "what would you like to do?\n" << "[0]add\n" << "[1]subtract\n" << "[2]exit\n";

cin >> input;
}

//subtract function
void subtract()
{
cout << "put in your first number:\t";
cin >> input;
number = input;

cout << "put in your second number:\t";
cin >> input;
number = number - input;

cout << "your resulting number is:\t" << number << endl;
}


//add funtion
void add()
{
cout << "put in your first number:\t";
cin >> input;
number = input;


cout << "put in your second number:\t";
cin >> input;
number = number + input;

cout << "your resulting number is:\t" << number << endl;
}


void checkInput()
{
//switch statement, i don't know if C# has these but i'll comment on it anyways
switch( input )
{

//if input = 0
case 0: add(); break; // <--break off of the switch statement (in case you didn't know)


//if input = 1
case 1: subtract(); break;


//if input = 2
case 2: running = false; break;

}
}


//our loop funtion
void loop()
{
while(running == true)
{
//call our funtions to run whatever we put in them
ask();

checkInput();
}
}


};


int main()
{
//make the calc class give everything in its class to a new item called program, (haha i dont know what this step is called i forgot)
calc program;

//set the bool variable to true
program.running = true;

//call the loop funtion to run
program.loop();

return 0;
}

//end of code /////////////////////////////

This topic is closed to new replies.

Advertisement