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
Newer posts →

The Curse of Typecasting – Solution

Posted on October 8, 2016 by dgookin
Reply

I hope you didn’t find this month’s Exercise too daunting. In fact, it’s pretty basic stuff, but often something you might forget. In fact, the compiler may remind you when you attempt to pass an argument to a function and it’s of the wrong type.
Continue reading →

Posted in Solution | Leave a reply

Take Your Turn – Solution

Posted on September 8, 2016 by dgookin
Reply

This month’s Exercise is to simulate turns in a game of tic-tac-toe (naughts and crosses). So the solution requires that you randomly work through available squares in the game matrix, alternating placement of an 'x' or 'o' token.
Continue reading →

Posted in Solution | Leave a reply

Your Card is Valid – Solution

Posted on August 8, 2016 by dgookin
Reply

Implementing a written algorithm is something you do frequently as a C language programmer. You’re given a set of directions and your job is to translate that English into computer code — and make that code work.
Continue reading →

Posted in Solution | Leave a reply

Tally the Digits – Solution

Posted on July 8, 2016 by dgookin
Reply

To solve this month’s Exercise, you must create a function that tallies digits in an integer value, what’s known as a digit sum. The key issue is how to peel off individual values in an integer and then total the result.
Continue reading →

Posted in Solution | Leave a reply

Find the Best Size Container – Solution

Posted on June 8, 2016 by dgookin
Reply

The C library contains various mathematical rounding functions, such as ceil(). That function, however, rounds up floating point values to the next integer. For this month’s Exercise, your job was to round up an integer to multiples of 16: 16, 32, 48, and 64.
Continue reading →

Posted in Solution | Leave a reply

Off to the Races – Solution

Posted on May 8, 2016 by dgookin
Reply

The purpose of the winner() function in the horse race game is to determine which value in an integer array is the largest. That would be an easy exercise to write, but it lacks the thrill and excitement of a horse race.
Continue reading →

Posted in Solution | Leave a reply

Read a Percentage Value – Solution

Posted on April 8, 2016 by dgookin
Reply

One of the things I enjoy about coding defensive input is that I get to think about all the oddball possibilities. Users can type anything, which is something you must always anticipate. For typing in a percentage value, the door for whacky input is left wide open.
Continue reading →

Posted in Solution | Leave a reply

Appreciation for Depreciation – Solution

Posted on March 8, 2016 by dgookin
Reply

This month’s Exercise is one of those old, programming warhorses: Calculate a depreciation schedule. At the simplest level, the solution is a mathematical loop and keeps subtracting a given percentage from a value.
Continue reading →

Posted in Solution | Leave a reply

Text Parsing Power – Solution

Posted on February 8, 2016 by dgookin
Reply

This month’s Exercise hosts a realm of possible solutions. So I present you with my three solutions, two of which are general and one specific.
Continue reading →

Posted in Solution | Leave a reply

Defensive Input – Solution

Posted on January 8, 2016 by dgookin
Reply

Writing an input routine isn’t that difficult in C. I cobble together simple input routines all the time. The scanf() function is brilliant for such situations. When you have to test input, things get dicey, which I hope you discovered as you attempted this month’s exercise.
Continue reading →

Posted in Solution | Leave a reply

Post navigation

← Older posts
Newer 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