Facebook Pixel

Four great C programming tests for beginners

By ILX Team | 6 January 2020

C is one of the most popular programming languages in the world. C’s versatility and flexibility gives programmers a high level of control with only minimal commands. This adaptability, coupled with its global prevalence, makes C a preferred language for those starting a career in programming.

As a mid-level language, C enables you to gain a good understanding of how computers execute code. For programmers who want to learn object-orientated languages like C++, C is an excellent place to begin. It’s also the basic starting point for all advanced computer languages, and forms a major part of Windows, Linux and UNIX. Learning C enables programmers to write embedded code that can be used in robotics, medical devices and automotive, essentially anything that requires the use of a microcontroller.

As with all languages, practice makes perfect. So, to help you out, we’ve suggested some beginner projects to put your C programming skills to the test.

1. The Hello World challenge in C

‘Hello World’ is a standard test for new programmers. The objective is to print the phrase ‘Hello World’ to console in C. This exercise can be completed in any programming language and is fun to do in competition with other programmers, to see who can complete the most languages in the shortest amount of time.

This exercise helps learners get familiar with the syntax and structure of the C programming language. It also helps with gaining an understanding of strings. If you’re keen to practice loops, you can try adding a loop to the code to display the phrase multiple times.

Access the Microsoft Hello World Tutorial.

2. Unit converter test in C

The challenge here is to convert height given in centimetres, to height given in feet and inches. This is a great test for beginners as it can be adapted to a variety of contexts, and enables the student to practice and demonstrate competence in using maths operators.

Access the Geeks For Geeks converter test.

3. Count the total number of vowels or consonants in a string using C

This test does what it says on the tin. Using your newfound skills, you simply have to write a program which can count the number of vowels or consonants in a string of letters. This is an excellent test if you are looking to improve your skills with functions, pointers and switch statements. It’s also great for those who need to practice using arrays and loops.

Access the W3 tutorial.

4. Check if a string is a palindrome using C

A palindrome is a word, number or phrase that reads exactly the same backwards or forwards. For example; ‘was it a rat I saw’, is an example of a palindromical sentence, and ‘radar’ is an example of a word that is a palindrome. If you write and reverse a string and it reads the same, we can say it is a palindrome string.

How to conduct the test:

  1. Take two pointers. ptr and rev, for example.
  2. Initialise ptr to the string’s base address and move it forward so it points to the last character in the string.
  3. Next, initialise rev to the base address of the string. Then, start moving rev in a forward direction and ptr in a backward direction at the same time until you reach the middle of the string.
  4. If at any point the character that is pointed to by ptr and rev does not match, then remove it from the loop.
  5. If ptr and rev crossed one another you’ve succeeded - the string is a palindrome. If not, try again.

You can also write the string without using pointers if you wish. Not only is this is a good exercise to practice string manipulation, it also helps you learn how to construct an algorithm to take an input and give an output. The degree of your experience will show in the efficiency of the algorithm.

Access the W3 Palindrome tutorial.

We hope these tests have helped you on your path to improving your C programming skills. Practice and experimentation are key to success, so if you don’t succeed the first time - or even the tenth - don’t give up! If you’re keen to level up from these there are tonnes of great C programming projects on GitHub to try.

Interested in improving your programming skills? Check out our full range of accredited courses today.

Our vision and values