Thread: Post your beginner/intermediate level C programming exercises here

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    244

    Post your beginner/intermediate level C programming exercises here

    Hello,
    I am trying to practice C programming on a regular basis... My professor gave everyone quite a few practice programs to work on. I finished all of them and was hoping for some you the forum members to post some good exercises that will improve beginner/intermediate level C programmers cover concepts such as: loops, arrays, i/o files, structs, recursion, link lists, functions, etc...

    Please post your programing exercises here (Please keep it beginner/ intermediate level).

    I will post some good ones myself in a short while.

    Thanks in advance

  2. #2
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    flame deleted.
    Last edited by Char*Pntr; 09-29-2010 at 12:55 AM.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    244
    Sorry for the duplicate threads, my computer froze then when I clicked submit it somehow created multiple new threads, please delete the extras.

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    244
    Quote Originally Posted by Char*Pntr View Post
    What are you nuts?

    Since you had enough intelligence to make it this far, how about going one more step:

    ----> Cprogramming.com FAQ
    Since you had enough intelligence to read my post, I asked for people to post practice program ideas. There arent any practice program ideas there.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    244
    Here are some practice program ideas:

    1)Write a program that allows a user to play a guessing game. Pick a random number in between 1 and 100, and then prompt the user for a guess. Based on their guess, then them that their guess is too high, too low, or correct. If the guess is not correct, reprompt the user for a new guess. Continue doing so until the user has properly picked the number.

    2)A file nintendo.in contains a single non-negative integer on each line representing donations (in dollars) to your Nintendo game buying fund. The end of the list will be signified by the value 0 on the last line of the file. (All other integers in the file will be positive.) A Nintendo game costs $50 to buy. Read in the file of donations and output a statement listing the maximum number of games you can buy as well as how much money you will have left over after buying that many games.

    3)Write a program that reads a set of dart throws from a user and computes the user's score. Assume that the user enters 21 dart throws and each throw is a single integer in between 1 and 20, inclusive. To compute the user's score, look at each number in between 15 and 20, inclusive that the user threw more than three times, and add up the points of the throws, after the third throw. For example, if the user throws 5 20s, 3 19s, 4 18s, 6 14s and 2 1s, then the user's score is 2x20+1x18 = 58, since the user threw 2 more 20s than 3 and 1 more 18 than 3. The 14s don't count since only 15 through 20 count for points.

  6. #6
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    deleted
    Last edited by Char*Pntr; 09-29-2010 at 12:55 AM.

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Char*Pntr View Post
    If you can't think of anything to code up using a homework, or something out of a textbook, then I really feel sorry for you.
    Where the hell is this coming from?

    What exactly is the material difference between an exercise from a book and an exercise posted by one of the community members here?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    deleted
    Last edited by Char*Pntr; 09-29-2010 at 01:13 AM.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    << This and that, water under the bridge. Moving on >>
    Last edited by Adak; 09-29-2010 at 03:19 AM.

  10. #10
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    Adak, I trust you and I think you're right. I'm sorry to everyone - Really, if the OP was serious, it should have been posted in the General forum. This was not a C specific question and I lost my temper.

    I apologize to everyone. Thanks Adak for your input, up until now, your thoughts on this was the only thing that made sense to me. Maybe you should be promoted to a mod here.

    Adak, if you'd like I can think of some programming examples to post on this thread.

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If you have some programming examples you'd like to post, please go ahead.

  12. #12
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    Quote Originally Posted by Adak View Post
    If you have some programming examples you'd like to post, please go ahead.
    I just now deleted all of my replies. It's late here, and I will post some examples here tomorrow.
    I'm reading K & R 2nd edtion, it's pretty enlightening.

    Thanks Adak!

  13. #13
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Since when has this forum become so hostile?

    If you just had a bad day, don't take it out on some random person on the internet. That's irresponsible.

    This thread does not deserve that kind of rude response.

    It's a genuine question by an inquisitive person. If you can't help, just move on to the next thread.

    To op:
    Judging by the examples you posted, I'm guessing you like more algorithmically challenging problems?

    Programming competition practice problems could be a good place to start -
    Try USACO, Canadian Computing Competition, IOI (this one is VERY challenging, most experienced/professional programmers won't be able to get most of the questions), or project Euclid.

    If you are a beginner in C they will be a little challenging, but challenges are good .

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    There are plenty of old homework questions posted on this (and many other) forums. How about reading them and seeing if you can do them? Don't bother to post the complete answer, just feel good that you know how to solve it.

    Also google "programming contests". There are sites with lots of problems, and automated checking of your answer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  15. #15
    Registered User
    Join Date
    Feb 2010
    Posts
    244
    Quote Originally Posted by Char*Pntr View Post
    deleted
    Why waste your time on responding to this thread if you are not going to be helpful? to try and make someone feel dumb over the internet...?? thats stupid. I feel sorry for YOU my friend.

    Move along...
    Last edited by matthayzon89; 09-29-2010 at 09:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post your games here...
    By Hammer in forum Game Programming
    Replies: 132
    Last Post: 02-28-2013, 09:29 AM
  2. Lost on Queues - Help GREATLY appreciated.
    By TetsuoShima in forum C Programming
    Replies: 3
    Last Post: 07-13-2010, 05:35 AM
  3. HTTPS POST with C Socket
    By pobri19 in forum Networking/Device Communication
    Replies: 14
    Last Post: 05-02-2010, 11:21 PM
  4. Post your Best Text Adventure
    By Joe100 in forum Game Programming
    Replies: 3
    Last Post: 08-15-2003, 05:47 PM
  5. Auto POST
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 06-07-2003, 10:42 AM