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 →

Check Your Stock Gains – Solution

Posted on July 8, 2021 by dgookin
Reply

The challenge for this month’s Exercise is to determine the greatest price gain for a stock during the trading day. The gain is calculated moving forward in time, from a low to a high. It’s easy to see with human eyeballs looking at a chart, but not so easy when you must code a solution.
Continue reading →

Posted in Solution | Leave a reply

Watch the Stock Market – Solution

Posted on June 8, 2021 by dgookin
Reply

Looks like your stock had a great day at the market. It bounced around, highs and lows, lots of nerves wracked and fingernails chewed, but the price ended higher on the day.
Continue reading →

Posted in Solution | Leave a reply

Unravel the Mystery Code – Solution

Posted on May 8, 2021 by dgookin
2

I hope you enjoyed crafting your solution for this month’s Exercise. It’s just for fun, as I assume no one is going to mess with C to such a degree that their code becomes so completely unrecognizable. Still, C coders are a mischievous bunch.
Continue reading →

Posted in Solution | 2 Replies

Balancing Accounts – Solution

Posted on April 8, 2021 by dgookin
Reply

I hope you had a wee bit of a struggle with your solution to this month’s Exercise. It involves a lot of decisions and proper steps in the right order to hold off on debits so that the bank account never dips below zero.
Continue reading →

Posted in Solution | Leave a reply

Positive, Negative, or Zero – Solution

Posted on March 8, 2021 by dgookin
6

Your challenge for this month’s Exercise is to write a sign() function, which returns 1, 0, or -1 depending on the sign of an integer. A relatively simple thing to code — I hope!
Continue reading →

Posted in Solution | 6 Replies

A Pair of Arrays – Solution

Posted on February 8, 2021 by dgookin
2

The challenge for this month’s Exercise is to initialize two different arrays to two sets of values. You should try to use only one loop and try to use a single statement to make the element assignments.
Continue reading →

Posted in Solution | 2 Replies

Find the Most Factors – Solution

Posted on January 8, 2021 by dgookin
Reply

The challenge for this month’s Exercise is to discover those values in the range 1 to 999 that have the highest number of factors. Never mind the math! Let C and the computer do the work for you.
Continue reading →

Posted in Solution | Leave a reply

Some Weighty Conversions – Solution

Posted on December 8, 2020 by dgookin
Reply

This month’s Exercise is to create a program that converts weight measurements by using this format:

nnnFT

Where nnn is a value, F is the unit to convert from, and T is the unit to convert to. This problem is more of an input-parsing exercise than a straight conversion.
Continue reading →

Posted in Solution | Leave a reply

Calculating Months – Solution

Posted on November 8, 2020 by dgookin
Reply

The task for this month’s Exercise is to return the month number for a time_t value. Effectively you extract the year and month, do some math, presto. Could it be this easy?
Continue reading →

Posted in Solution | Leave a reply

A Cumulative Total – Solution

Posted on October 8, 2020 by dgookin
Reply

I find it odd that the recursive solution for this month’s Exercise is far shorter than the non-recursive version. Yet, it has an elegance that’s evident in lots of recursive code examples.
Continue reading →

Posted in Solution | Leave a reply

Post navigation

← Older posts
Newer posts →

Recent Posts

  • The Ever-Expanding Pointer Array
  • Heron’s Formula – Solution
  • Coding a Better stringcopy() Function
  • Heron’s Formula
  • Copying Strings

Recent Comments

  • dgookin on Heron’s Formula
  • Chris Webb on Heron’s Formula
  • dgookin on Heron’s Formula
  • Chris Webb on Heron’s Formula
  • dgookin on Finding Those Pesky Null Characters!

Meta

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

Copyright © 1997-2025 by QPBC.
All rights reserved

Proudly powered by WordPress