Beginning Programming with C For Dummies Code Files
A Taste of Recursion
The Double-Linked List

10 Programming with C Coding Exercises

If you're just beginning with C programming, test your skills with these projects. Answers for these exercises are not provided on the website. It's up to you to complete them, using your knowledge of C. Good luck!

Project 1

Create a program that grabs a string of text and then totals the values of all characters in the string (as integers).

Project 2

Create a program that displays the first 100 prime numbers.

Project 3

Create a program that draws five random numbers, like a Lotto drawing. Ensure that the same number isn't drawn twice.

Project 4

Create a program that reads words from a text file and reassembles the words in random order.

Project 5

Create a program that simulates a deck of cards. Draw five cards from the deck.

Project 6

Create a program that reads standard input and sends to standard output the hexadecimal values of the characters input, separated by spaces.

Project 7

Create a program that simulates the roll of a die. Have the program output the rolls of six dice repeatedly until at least four of the dice roll the same number.

Project 8

Create a program that reads a directory, storing information on each of the files in a structure. The structures are then displayed and sorted by file size, from smallest to largest.

Project 9

Code a program that takes the value of a long int and rotates the bit values so that the new value has bits set from left to right rather than from right to left. For example, if the original value is 01010011, the output is 11001010.

Project 10

Write a program with a function that converts a string of digits into an integer value. Do not use the strtol() function or any other standard C library function. Write your own!

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Understanding the Header File
The sprintf() Function