fun, easy programs for beginners

Okay, already loving this forum ^^

im looking for easy projects somebody who just started c++ a few days ago can do,

to get a better understanding of my skill i wrote that code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;

int main()
{
    string name;
    int age;
    string Lname;
    cout << "Enter your name" << endl;
    cin >> name;
    cout << "Enter your last name" << endl;
    cin >> Lname;
    cout << "Enter your age" << endl;
    cin >> age;

}
myself, if you guys have any ideas, i would love to hear them!
Haha, starting up is always fun =]

If you're interested in projects, there are all sorts of things online that you can look at for ideas, just google around- I'm sure you'll find some stuff.

As far as some ideas, here are a couple:

1. Write a journal program. Something to keep track of your days. This is a nice program that you can work on as you get better, as you learn file IO you can learn to save your files, when you get to stringstream you can save your entries based on the date or the number of seconds since jan 1, 1970 (see time(0) in time.h) and if you want to you can learn basic encryption so people can't read your journal entries, then have passwords to retrieve your files, then when you start GUI programming you can implement the whole thing into a GUI =]

2. Make a quick game you can play with friends, to get more people involved in your success. The more people encouraging you the better. Something simple would be a hangman game, or maybe a number guessing game, or perhaps a lexicon game.

3. Make a decision maker. Something that you can input the decision you'd like to make, and the possible outcomes, the computer will then decide for you.

4. Make an alarm clock- or a timer, something that will inform you at a certain time of the day that something needs to be done, or stopped. Then utilize it for your programming for a paradigm of xx minutes of programming followed by xx minutes of break.

5. After your other projects are done, and you're much more confident, start learning a 3rd party library. Something that will allow you to get outside of the console into an exciting world of graphics and guis and sounds =] Make a game, from beginning to end- don't move on until it's done.

How's that?
Okay i will, ill do your ideas first, of course spacing out a few as i will need to learn some more things befor i can make a game, or alarm clock....

but thanks for the ideas and i will get to work on em,
Definitely. Looks like you have the basics of strings- but you have a ways to go yet =]

Things I'd recommend learning:

Everything. =]

nah, just kidding


Good things to learn at this point:

http://cplusplus.com/doc/tutorial/

functions http://cplusplus.com/doc/tutorial/functions/
fstream http://cplusplus.com/doc/tutorial/files/
stringstream http://cplusplus.com/reference/iostream/stringstream/
rand() http://cplusplus.com/reference/clibrary/cstdlib/rand/
Done with part of the journal,

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <fstream>
using namespace std;

int main(){
string j;
ofstream Cplusplusjournel;
Cplusplusjournel.open("H:\\cplusplusjournel\\journal.txt");
cin >> j;
Cplusplusjournel << j << endl;

}
 


just need to work on it a bit more, have it add the time and date when the log is created ^^

speaking of.. is there a code that DOES output the date/time? =D
Last edited on
Yes, there are some things you can do to get the current date/time, here's a simple way :

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
37
38
39
40
41
42
#include <ctime>
//...

int         getMonth(time_t timeval){
 struct tm * timeinfo;
 timeinfo = localtime(&timeval);
 return timeinfo->tm_mon + 1;
}
int         getDay(time_t timeval){
 struct tm * timeinfo;
 timeinfo = localtime(&timeval);
 return timeinfo->tm_mday;
}
int         getYear(time_t timeval){
 struct tm * timeinfo;
 timeinfo = localtime(&timeval);
 return timeinfo->tm_year+1900;
}
int         getHour(time_t timeval){
 struct tm * timeinfo;
 timeinfo = localtime(&timeval);
 return timeinfo->tm_hour;
}
int         getMin(time_t timeval){
 struct tm * timeinfo;
 timeinfo = localtime(&timeval);
 return timeinfo->tm_min;
}
int         getSec(time_t timeval){
 struct tm * timeinfo;
 timeinfo = localtime(&timeval);
 return timeinfo->tm_sec;
}
std::string getWeekday(time_t timeval){
  struct tm * timeinfo;
  std::string days[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"}; 
    //could just make this global

  timeinfo = localtime(&timeval);

  return days[timeinfo->tm_wday];
}


This is a quick little collection of functions to return current date properties
thats odd, when i do that it doesnt give me any errors, but it only outputs one line, "1"
1
2
3
4
 

Cplusplusjournel << localtime << endl;
 

is what i want to output, correct?
Hahahaha, well you don't want to output localtime. it's a function, here's how you'd use those functions:

1
2
3
4
//include stuff first, make sure function declarations are above

cout << "\nThe Current Date Is : ";
cout << getMonth(time(0)) << "/" << getDay(time(0)) << "/" << getYear(time(0));
Aha! okay sorry, again im new haha
Not a problem, have a great time.
This looks fun. I'm relatively new myself and this is a great way to get things going.
Topic archived. No new replies allowed.