{"id":4791,"date":"2021-06-01T00:01:34","date_gmt":"2021-06-01T07:01:34","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=4791"},"modified":"2021-06-08T07:14:16","modified_gmt":"2021-06-08T14:14:16","slug":"watch-the-stock-market","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=4791","title":{"rendered":"Watch the Stock Market"},"content":{"rendered":"<h2>Difficulty: Medium<\/h2>\n<p>Stock prices fluctuate throughout the day based on news, fear, and speculation. If you own stock and desire the price to rise, you anxiously watch the stock tickers throughout the day, puzzled or delighted by the reactions. This month&#8217;s Exercise attempts to emulate such anxiety.<br \/>\n<!--more--><br \/>\nAssume that the stock market opens at 9:00 AM. Your stock is priced at $8\/share. Every 30 minutes the stock ticker is updated, reflecting the new price for your stock, until the market closes at 4:00 PM:<\/p>\n<p><code>&nbsp;9:00 Price $8\/share<br \/>\n&nbsp;9:30 Price $9\/share<br \/>\n10:00 Price $7\/share<br \/>\n10:30 Price $6\/share<br \/>\n11:00 Price $8\/share<br \/>\n11:30 Price $10\/share<br \/>\n12:00 Price $12\/share<br \/>\n12:30 Price $11\/share<br \/>\n&nbsp;1:00 Price $10\/share<br \/>\n&nbsp;1:30 Price $13\/share<br \/>\n&nbsp;2:00 Price $11\/share<br \/>\n&nbsp;2:30 Price $5\/share<br \/>\n&nbsp;3:00 Price $8\/share<br \/>\n&nbsp;3:30 Price $9\/share<br \/>\n&nbsp;4:00 Price $11\/share<\/code><\/p>\n<p>Obviously it was a good day for your stock: The price started at $8\/share, and though it bounced around all day, it ended up at $11\/share. Woo-hoo.<\/p>\n<p>Your challenge for this month&#8217;s Exercise is to reproduce the above stock market ticker output. Yes, I know that the US stock markets open at 9:30 AM Eastern time, but this is a programming exercise and not a reflection of reality.<\/p>\n<p>Use the following integer array in your code:<\/p>\n<p><code>int stock_price[] = {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;8, 9, 7, 6, 8, 10, 12, 11,<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;10, 13, 11, 5, 8, 9, 11<br \/>\n};<\/code><\/p>\n<p>The <code>stock_price[]<\/code> array represents stock prices taken at 30 minute intervals. Your task is to output these values as shown above, along with the timestamps from 9:00 AM through 4:00 PM.<\/p>\n<p>You may find this Exercise to be a little bit on the easy side of &#8220;medium&#8221; difficulty. That&#8217;s fine. For July&#8217;s Exercise, this code is taken one step further into the &#8220;hard&#8221; level of difficulty. Be forewarned!<\/p>\n<p>Please try this Exercise on  your own before you peek at <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=4797\">my solution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Devise a program that outputs stock prices at the 30 minute mark throughout the trading day. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=4791\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-4791","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4791"}],"version-history":[{"count":4,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4791\/revisions"}],"predecessor-version":[{"id":4820,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4791\/revisions\/4820"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}