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!
Create a program that grabs a string of text and then totals the values of all characters in the string (as integers).
Create a program that displays the first 100 prime numbers.
Create a program that draws five random numbers, like a Lotto drawing. Ensure that the same number isn’t drawn twice.
Create a program that reads words from a text file and reassembles the words in random order.
Create a program that simulates a deck of cards. Draw five cards from the deck.
Create a program that reads standard input and sends to standard output the hexadecimal values of the characters input, separated by spaces.
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.
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.
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.
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!