LearnFrenzy
Sign in Take a free test

C Const · Exercise 4 of 4

C Const const Programs

  • 8 questions
  • Page 1 of 1
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Programs that use const, constant tables and C23 constexpr the professional way. Write each one yourself first, then open the solution – every solution was compiled and run, and the output shown is the real output.

Question 1 Medium

Convert integers to Roman numerals using two parallel static const tables.

Question page & discussion
Question 2 Easy

Return the full month name for 1–12 and "invalid" otherwise, using read-only data.

Question page & discussion
Question 3 Easy

Write a function that counts letters, digits and spaces in a string it only reads, returning the counts through pointers.

Question page & discussion
Question 4 Medium

Look up a product category's GST rate in a read-only table and compute the final price in paise.

Question page & discussion
Question 5 Medium

Keep default settings in a static const struct and build user settings by copying and overriding them.

Question page & discussion
Question 6 Easy

Convert one value with several conversion factors stored in a read-only table.

Question page & discussion
Question 7 Easy

Write max_of() that finds the largest element of an array it promises not to modify, and call it with both a const and a normal array.

Question page & discussion
Question 8 Hard

Using C23 constexpr for the size, build and print a 4 × 4 identity matrix in a file-scope array.

Question page & discussion
All exercises doneBack to C ConstRevise the concepts or pick another topic

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links