C++ Test Project

Hi I am new to this forum and relatively new to C++. I have read about 2 books on it already and I understand stuff like loops, when to use for loop and when to use while ect, prefix incrementing/decrementing and suffix incrementing/decrementing, variable, constants all that kind of stuff. So before I go onto OOP I would like to test myself by writing a C++ program without any aids to prove that I can actually program in C++. So I was wondering if you people in this community could post some ideas of projects that I could do. Nothing like involving UIs as I have no idea how to intergrate a UI with my code. I am on a mac so ye I have Interface builder but I have no idea how to use it for C++ lol and to my knowledge I dont think you can.

So you bottom line, could you post some pretty simple but challenging projects for me to work on as a test.

If you could also help me out by giving me some guidelines for making UI that would be perfect.

Nothing too hard :) Im only 12 :P Ha ha.

OK

Thanks for reading

Arcadiu
Well my young friend, I'm new to this forum as well, but I'm not so new to c++. IF C++ is your first language, then kudos. It can be a bit daunting for a programming newbie.


Now as for a project, I'll give you the same first project I gave to my 10 year old brother when i was teaching him basic.


Write me a program that acts as a survey. Asking various questions and storing the answers. And at the end display a message containing all the answers in paragraph form.

If this is too easy for you, incorporate some boolean logic. IE depending on what they say for their answers, change what the next question will be.

If you want, use some functions and define some classes for it, though you wouldn't need too.


It's pretty basic. If it's too basic, then forgive me if I've insulted you. Else, have fun my friend :)



-cheers
Some ideas I did when I (was) a beginner:
Eaiser: 1.
Develop some shorting algorithms which accepts an array and sorts in :
Bubble short, Insertion short, etc (wikipedia for more)

Medium: 1.
Make a tic-tac-toe game.
Let two players play.
Check for winning/draw conditions.
table should look something like this:
1
2
3
X O
OX
 OX

Also you can make a bot, which plays from random to perfect.

Harder: 1.
Input:
A normal mathematical expression like
6*(5+42/2)^2+1
Converting it to postfix which should look something like this
42 2 / 5 + 2 ^ 6 *1 + (hope thats good :| )
Look up postfix notation on wikipedia.
You can make it easier my leaving out parenthesis, or harder by adding other operators like:
1
2
! (factorial)
abs sin cos etc...

2.
Given a 2D array of chars like
1
2
3
4
5
6
7
SFFFFFFFFF
FFFFFFFFFF
FFWFFFFWFF
FFWFFFFWFF
FFWFFFFWFF
FFFFFFFFFF
FFFFFFFFFE

search for the (shortest) route between 'S' and 'E', where F represents a Free node, and W a wall.
Output the result is some form (whatever is the easiest).
Make it work on an arbitrary map.
If you ever learn any graphical library, you can make a very nice program out of this.

Thats for now, If anything else comes into my mind I will tell you!



Edit:
I just see you haven't learned classes yet. some of those might be a little hard without them, I recommend only the sorting algorithms or the infix to postfix conversion, the others might be a future project :)

Last edited on
R0Mai thats too hard lol but thankyou for replying. I don't no what aligorithms are. Well is it something that you repeat over and over again and after so many times you return to the original value??

Seraphimsan, I progeammed with a version of PASCAL in a IDE called SCAR when I was 9 (Shit compared to auto rune). Basically, it was a language UBER userfriendly that like a 9 year old could do it and it was for cheating in flash games and browser games. I generally used it for runescape when i was 10.

But C++ is my first proper language. I can do HTML,CSS and XHTML very well and learning C# atm. I only really came back to C++ because I hadn't done it in a long time. Last time i properly went for it was like half a year ago so i started it again.

Those challenges are perfect thankyou

Should the survey store only 1 persons answers or more? I know nothing about OOP unfortunately or the dreaded pointer :P

R0mai could you show me how I could do tic tac toe? I have no idea how to automate the computer.

The first hard one, do you mean create a program that turns a expression into postfix notation? I will be sure to try that out asap when I am confident I can do it :)

Thanks guys


Keep 'em going too :P
lol pascal was one of my first ones :P


Well since your new to object oriented programming, (Although i think css is OOP) forget about the functions and classes.

For an easier project only store one users input.


For a medium project store as many as their are users who want to use the program.


for a harder one put a cap on the amount that could use it. Say after 5 users take the survey dont allow any to use it again. Wait...that would require outputing data to a file... If you meant with looping the program, do it if you please.

if not, do the cap thing.

edit: and just a word of advice, you may find out very soon in you programming ventures that hacking into your schools system for what ever reason would be very easy. For the love of god and all that is holy dont do it. I'm sure this is common sence, but god knows I did it. As satasifying as it is to see 22 computers shut off simultaneously (at the group closing of Microsoft word in a lab) it's not worth the trouble :P


// end off topic //
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;


char favouriteSeason[125];  // Making global variables... is that ok??
char favouriteColour[125];
char doYouLikeThisSurvey[125];
char whatOsAreYouRunning[125];


int main() {


system("clear"); //Yes i will probably get flamed for using system()
				//functions because of the gaping secury flaw but its
			   //not as if clearing the screen is a necessity?
	

cout << "Hello and welcome to Arcadiu's survey. The survey shall be";
cout << "about you :). Please answer honestly.\n";
cout << "Question 1: What is your favourite season? (1) Summer (2) Autumn (3) Winter (4) Spring.\n";
cin >> favouriteSeason;
cout << "Question 2: What is your favourite colour? (1) Green (2) Blue (3) Red (4) Orange (5) Yellow (6) Other.\n";
cin >> favouriteColour;
cout << "Question 3: Do you like this survey? (1) Yes (2) No (3) Its alright \n";
cin >> doYouLikeThisSurvey;
cout << "Quesiton 4: What OS are you running? (1) Windows XP (2) Windows Vista (3) OSX (4) Linux (5) Solaris\n";
cin >> whatOsAreYouRunning;
cout << "And that is the end of the survey. Your answers are as follows:\n";
cout << "For question one, you said:" << favouriteSeason  << endl;
cout << "For question two, you said:" << favouriteColour << endl;
cout << "For question three, you said:" << doYouLikeThisSurvey  << endl;
cout << "For question four, you said:" << whatOsAreYouRunning  << endl;
	return 0;
}



Yes shit standards but idk them atm. I was going to implement boolean logic like you said but i have to go to get off for the night now. I also was going to implement a fool proof system but again i didnt have enough time just like a "repeat the survey" choice aswell until the answer was no which would then abort the program.

Please tell me if I pass or fail :) thanks
Last edited on

I don't no what aligorithms are.
From Wikipedia
an algorithm is a finite sequence of instructions, an explicit, step-by-step procedure for solving a problem

So : A sorting algorithm is a method to convert a shuffled array of ints to a sorted one:
1
2
3
4
5
6
7
8
9
10
11
12
13
void my_sortint_method(int array[], int size_of_array);

int main() {
	int my_array[] = {3, -1, 23, 22, -2344, 9};
	my_sortint_method(my_array, 6);

}

void my_sortint_method(int array[], int size_of_array) {
	//*** here goes your algorithm
	//So it will swap the values in the array to make from {3, -1, 23, 22, -2344, 9} array
	//to {-2344, -1, 3, 9, 22, 23} array
}


I don't know how much you know about arrays, if you haven't learned it yet, then this is again will be only your future project :)

do you mean create a program that turns a expression into postfix notation?

exactly
That might be too hard for you yet, you will have to use stacks, and do string manipulation.
I recommend googling for Shunting yard algorithm. I actually used classes also for this to make it more robust.


You are going to be a great programmer if you know that much about programming and you are still 10. Keep it up :)

If you need any help on the above topics, just ask :)
Well, as Your new to C++ I'd pass you, but just barely. Really the only way I'd fail anyone in a begginers C++ class is if every single line had an error.


So there wasn't anything really did wrong, just poorly, and I understand that you were off to bed for the night.

First of all, global variables are fine in this case.

Now personally I would of just used strings but you would need to put #include <string.h> (possibly sans .h)

next thing i would improve upon, would be how you output the questions. Simply adding an extra \n here or there would help. I know its nitpicky, but still constructive.

One last thing I would work on is your indenting, it helps for the flow of the code when being read by another programmer.

Now the one thing you failed to do, was pause the terminal before closing it. So No user could see the final output. Which is why you almost failed (and to most teachers, did fail).

the easiest way of doing that is system("PAUSE");


edit: I agree with R0nai. keep it up :)
Last edited on
Just for future reference.

<string.h> is not the same as <string>

Using a newer compiler <string.h> will be interpreted as <cstring>

Try not to use depreciated headers.


hmm I stated in my first post i was on a mac so I have no need for the system pause command sorry for not stating it clearly :(. Thanks for pointing the rest out and also yes ages and ages ago I could "hack" into my school network. Right now I could go onto a school computer and promote myself admin and screw up the whole network and settings like changing homepages to "other" things lol and i duno other stuff but im not really into hacking but ye i know its not worth it but i always dream of on the last day of school implementing a trojan horse with a backdoor in so i could get in from my pc :)

what happened when you did it lol


Thank you eker676
Well, two kids from my school actually placed a backdoor on the school computers. They no longer go to my school. They were expelled. If you want to screw up your future go ahead but I strongly suggest against it. ;)
hmm ye i thought that would happen if you were screwing up the network

did they import anything thru the backdoor?if so what? how did it get on?

thats the reason why u do it on the last day of ur schooling :) u have ur exam marks and ur outa school :)

got any ideas for a project?
http://www.cplusplus.com/forum/beginner/3473/

Last day of school doesn't matter. It is a criminal act using a computer to commit a crime. (Not a fun thing to mess with)
eker is right. I put those childish ways behind me for fear of getting caught, and I'm never going back. I'm sorry I brought it up...

And thanks Eker for the comment on strings I couldnt remember which was current, slight memory laps.
Well, you can come tomorrow to my Data Structure Course and take the 8 Pages Test for me :|
Xp since I'm sick but the teacher its so inhuman that he doesn't give reposition... So I will go with my sickness and pass it to him... >:}

lol
its not so hard....

Just few rand, srand, inline, Default Arguments, Reference Arguments, Recursion, Iteration...

God Will Help you as he help us :)
Last edited on
Topic archived. No new replies allowed.