Science Forums: Any Programming challenges for a C++ beginner? - Science Forums

Jump to content

Welcome to ScienceForums.Net!

Welcome to ScienceForums.Net! We welcome science discussion at all levels — from beginners to researchers, covering topics from biology to computer science, and much more. Registration is fast and free, and allows you to post on the forums, so register now and join the discussions!
  
After you've registered, come in and introduce yourself, or visit the forum index. If you need any help  registering, posting, or if you just have some questions about our site, please feel free to contact us at staff at scienceforums dot net.

  • Start new topics and reply to others
  • Subscribe to topics and forums to get automatic updates
  • Create a ScienceForums.Net Blog!
Guest Message © 2012 DevFuse
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Any Programming challenges for a C++ beginner? Rate Topic: -----

#1 Equilibrium 


Quark
I'm starting to learn C++ but I would like to find some problems to practice my skills on. I don't know that much except for the very basic like looping and if-statements (Didn't learn to make a class yet because I'm preoccupied with studying for midterms as of now).

So does anyone have something I can work on or a website with things of this sort?

Thanks.
"Should we force science down the throats of those that have no taste for it? Is it our duty to drag them kicking and screaming into the twenty-first century ? I am afraid that it is."— George Porter (1920- ), British chemist

"When you are courting a nice girl, an hour seems like a second. When you sit on a red-hot cinder, a second seems like an hour. That's relativity."— Albert Einstein

"Nature is trying very hard to make us succeed, but nature does not depend on us. We are not the only experiment."— R. Buckminster Fuller

Can't we just get along? (To the bickering children in the religion section)
0

#2 timo 


Primate
Create a class "Polynomial" that represents functions of the type f(x) = a_0 + a_1 x^2 + a_2 x^2 (hint: constructor)
  • Create a method of that class that prints out pairs of x and f(x) over a specified range and with a specified distance between subsequent x. An output of this would look like
    x f(x)
    -1  0.5
    -0.8 0.4
    -0.6 0.3
    -0.4 0.2
    
    (hints: method, std::cout)

  • Do the same but write to a text file rather than the screen (hint: std::ofstream)

  • Not directly C++ related by arguably even more important for a scientist: Plot these data with a program of your choice to visualize the function. Use the program's built-in function parser to verify that the data you were writing out is correct. (hint: gnuplot)

  • Extend the class to handle functions of the type f(x) = a_0 + a_1 x^2 + a_2 x^2 + \dots (hint: std::vector)

  • Implement an algebra over these objects, i.e. overload operators such than you can add two of these objects ( f^{(1)}(x) + f^{(2)}(x) = (a_0^{(1)} + a_0^{(2)}) + (a_1^{(1)} + a_1^{(2)}) x + \dots ) and allows to multiply them with a real ( d * f(x) = d*a0 + d*a1*x + ...) (the term is "operator overloading").

  • Implement a method that finds the maximum f(x) over a given range [x0; x1] (no hint: there's several ways and the purpose of this task already is to spark your ambition to try out things for yourself).

This program should be appropriate for a ambitious beginner, teach some basics of c++, and keep you occupied for some time (so don't worry if you are not finished with all those points after a day).

This post has been edited by timo: 10 January 2012 - 11:01 PM

Forum madness is no excuse for forum rudeness (after H.J. Farnsworth)
0

#3 TimeContinuum 


Quark
Can you program me a 3d model simulation?
0

#4 User is online  Xittenn 


Atom
Learning to program 3D Animations using DirectX or OpenGL are probably the most amusing projects to help you learn C++ IMO. This also teaches you to work with developed libraries, develops understanding of program structure, and also forces you into using most of the features of the language. Although bone animation can be a little tricky in terms of mathematics and a good understanding of the related matrix mathematics is necessary, learning these can be fairly simple as well. There are a lot of online resources that explain how to do these things, where I'm not so sure the depth of information is covered in other topics like extranet banking transactions.
"He is their god! He leads them like a thing made by some other deity than Nature that shapes man better. And they follow him against us brats with no less confidence than boys pursuing summer butterflies, or butchers killing flies." - Cominius; Shakespears Coriolanus
0

#5 NotanOriginalName 


Quark
WAP which prints its own source code.Its rather easy but really interesting for a starter.Posted Image
0

#6 User is online  khaled 


Meson

View PostNotanOriginalName, on 19 January 2012 - 02:45 PM, said:

WAP which prints its own source code.Its rather easy but really interesting for a starter.Posted Image


A Quine, a code that prints its own source code. It's not an easy thing, at least for understanding how it's done.

.. do you know what is the shortest Quine ?

Spoiler

Everything is a graph

twitter: @khaledkhunaifer, Blog: KhaledKhunaifer:Blog
0

#7 Cap'n Refsmmat 


Icon
Mr. Wizard
You can play with problems from Project Euler:

http://projecteuler.net/
Cap'n Refsmmat
SFN Administrator

Get in the chatroom!
0

#8 Schrödinger's hat 


Icon
Psychic Sexpert

View Postkhaled, on 19 January 2012 - 08:38 PM, said:

A Quine, a code that prints its own source code. It's not an easy thing, at least for understanding how it's done.

.. do you know what is the shortest Quine ?

Spoiler



Not always.
~> touch Empty.java
~> javac Empty.java
~> java Empty
Error: Could not find or load main class Empty


Some compilers/interpreters will choke (giving you output that is not in your source in the form of error messages), or not produce any program output.
The latter could be argued to be a Quine, but it all gets rather philosophical.
What is the output of a program that does not exist?
I'd say it's undefined, rather than nothing.

Mysticism aside, I should address the OP.

Equilibrium:
My own favourite source of problems of this type is project euler http://projecteuler.net/
They're very math oriented, so may or may not be to your liking.

Other than that, some 3D programming as has been suggested would be the way to go.
I don't believe in free will, but I choose to pretend it exists. If I'm helpful press the green button--->
0

#9 Ben Bowen 


Meson
Although 3D graphics are extremely interesting (one of my largest interests), you're a beginner and you should start with a more simple and easy to complete project.

Way back when I was first learning C++, I made a console-based restaurant tycoon game. It was a relatively easy project and very fun to play with. Like this:

Quote

Patrick's Food Franchise!

Main Menu
1 - New
2 - Load File
3 - Quit

[user enters 1]

You started a new game.
Day 1.
$40000, 1 restaurant(s).

1 - I'm ready. Begin a new day.
2 - Manage the HQ office.
3 - Manage a restaurant building.
4 - Build a new restaurant building (COST: $125000).
5 - Save game.
6 - Go to main menu.

[user enters 3]

Choose the restaurant building you want to manage:
1 - Capital [LEVEL 1]
2 - Cancel

etc...


That's just an example of how you can do it. You can integrate all kinds of strategic elements, upgrades and research trees (like marketing insight, or special restaurant equipment) etc.

Have fun!

This post has been edited by Ben Bowen: 2 February 2012 - 11:25 PM

0

#10 lightburst 


Quark
One teacher told me to try and make your own implementation of some of the functions of an STL. You could do that for some of the generic algorithms I suppose. Of course this is assuming you're new to programming in general.
0

#11 User is online  Xittenn 


Atom

View Postlightburst, on 5 February 2012 - 12:08 PM, said:

One teacher told me to try and make your own implementation of some of the functions of an STL. You could do that for some of the generic algorithms I suppose. Of course this is assuming you're new to programming in general.


Emulating STL functionality is a great way to learn to program, I wouldn't say that it presents an appropriate challenge level for a beginner though. I think that one should learn how to use a standard vector<> before learning translation units, memory management, template programming, sorting algorithms, and hashing etc. Just my opinion though, I would approach this as an intermediate programmer.
"He is their god! He leads them like a thing made by some other deity than Nature that shapes man better. And they follow him against us brats with no less confidence than boys pursuing summer butterflies, or butchers killing flies." - Cominius; Shakespears Coriolanus
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users