Skip to primary content
Skip to secondary content

C For Dummies Blog

Main menu

  • C For Dummies (home)
  • History
  • Series
  • Supplemental
  • Blog Miscellany

Category Archives: Solution

Post navigation

← Older posts

Is It a “Real” Triangle? – Solution

Posted on January 8, 2026 by dgookin
2

The challenge for this month’s Exercise is to generate three random values and determine if they work as sides of a valid triangle. To make this determination, you must consider three types of triangles and test the generated values for each.
Continue reading →

Posted in Solution | 2 Replies

Which is Greatest? – Solution

Posted on December 8, 2025 by dgookin
Reply

The task for this month’s Exercise is to write a function, greatest(), that returns the largest of three values. While this task could be done easily with an if-else construction, the second part of the challenge is to write the entire thing as a single ternary statement. How’d you do?
Continue reading →

Posted in Solution | Leave a reply

Having Fun with goto – Solution

Posted on November 8, 2025 by dgookin
Reply

This month’s C programming Exercise is probably the most bizarre one I’ve ever offered! Using the goto keyword is frowned upon, which means that your C programmer brain is unaccustomed to thinking about using goto to construct, well, anything!
Continue reading →

Posted in Solution | Leave a reply

Heron’s Formula – Solution

Posted on October 8, 2025 by dgookin
1

The challenge for this month’s Exercise is to code Heron’s Formula. This geometric magic calculates the area of a triangle given the length of each of its three sides.
Continue reading →

Posted in Solution | 1 Reply

The Reversing Words Filter – Solution

Posted on September 8, 2025 by dgookin
2

The task for this month’s C programming Exercise is to code a filter that reverses single words. As a filter, the code deals with standard input and output, but it must store this input in word-sized chunks for the reversing process to work.
Continue reading →

Posted in Solution | 2 Replies

Your Name in Base 36 – Solution

Posted on August 8, 2025 by dgookin
Reply

My solution for this month’s Exercise didn’t require much work. What I did was to “stack overflow” the problem by pulling in functions from earlier Lessons. The only new portion of code deals with processing the input before sending the string off to the b36_decimal() function I’ve already written.
Continue reading →

Posted in Solution | Leave a reply

The Reversing Filter – Solution

Posted on July 8, 2025 by dgookin
2

This month’s Exercise presents more than a traditional filter. Instead of input being processed and immediately output, the input must be stored. Further, the storage quantity is unknown. Therefore, to provide proper storage the code must employ an expanding buffer. This condition means that the solution relies upon the scariest aspect of C programming: pointers!
Continue reading →

Posted in Solution | 2 Replies

Pick the Base – Solution

Posted on June 8, 2025 by dgookin
2

Your task for this month’s Exercise is to write a program that outputs a value in any base, between 2 and 10. Sure, you can use this code to communicate with alien species that use a base other than decimal, but this benefit is only a happy coincidence to the exercise.
Continue reading →

Posted in Solution | 2 Replies

Formatting a Series for Output – Solution

Posted on May 8, 2025 by dgookin
Reply

The challenge for this month’s Exercise is to output a series of numbers, 1 through 10, and to ensure that the final number doesn’t look dorky. I’m certain that’s what I asked for.
Continue reading →

Posted in Solution | Leave a reply

Keep Finding That String – Solution

Posted on March 8, 2025 by dgookin
Reply

The task for this month’s Exercise is to repeatedly call the strstr() function, locating all instances of one string (“needle”) inside another (“haystack”). Obviously your first task, which also helps with the solution, is to perform error checking on the return value from the strstr() function.
Continue reading →

Posted in Solution | Leave a reply

Post navigation

← Older posts

Recent Posts

  • Cooked or Raw?
  • Is It a “Real” Triangle? – Solution
  • Getting and Setting the File Position Indicator
  • Is It a “Real” Triangle?
  • A Colorful Hexdump

Recent Comments

  • dgookin on Is It a “Real” Triangle? – Solution
  • Chris Webb on Is It a “Real” Triangle? – Solution
  • dgookin on A Colorful Hexdump
  • Chris Webb on A Colorful Hexdump
  • dgookin on Code Page 437

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 1997-2026 by QPBC.
All rights reserved

Proudly powered by WordPress