{"id":1138,"date":"2015-01-01T00:01:26","date_gmt":"2015-01-01T08:01:26","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=1138"},"modified":"2015-01-08T20:30:06","modified_gmt":"2015-01-09T04:30:06","slug":"just-average","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=1138","title":{"rendered":"Just Average"},"content":{"rendered":"<p>Among the tools missing from the C library, which are ample in other programming languages, are functions that manipulate arrays. I&#8217;ve seen functions in other programming languages that slice, dice, mince, and chop an array. One of the more common functions calculates the average of a numeric array.<br \/>\n<!--more--><br \/>\nFor example, some other programming language may have an <em>average()<\/em> function. You send the function an array &#8212; or raw values &#8212; and it spews back the average of all the numbers. And that just happens to be your Exercise for the month of January, 2015.<\/p>\n<p><em>Happy New Year<\/em>!<\/p>\n<p>The following code skeleton contains the array you need to average. It also contains other information you can use to concoct your own <em>average()<\/em> function.<\/p>\n<pre class=\"screen\">\r\n#include &ltstdio.h&gt;\r\n\r\n#define COUNT 10\r\n\r\nint main()\r\n{\r\n    float scores[COUNT] = {\r\n        97.2, 86.0, 75.5, 93.2, 87.1,\r\n        68.7, 81.9, 92.4, 84.0, 66.3 };\r\n    int x;\r\n\r\n    for(x=0;x&lt;COUNT;x++)\r\n        printf(\"Student %2d score %3.1f\\n\",x+1,scores[x]);\r\n    <span class=\"comments\">\/* display average score *\/<\/span>\r\n\r\n    return(0);\r\n}\r\n\r\naverage()\r\n{\r\n}<\/pre>\n<p>Your task is to create the <em>average()<\/em> function, supply its arguments (important), and stick that function in the appropriate spot in the <em>main()<\/em> function.<\/p>\n<p><a href=\"http:\/\/c-for-dummies.com\/blog\/?p=1141\">Click here<\/a> to read about my solution, although I strongly encourage you to first try this Exercise on your own.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Calculate the average of an array of values. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=1138\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1138","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\/1138","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=1138"}],"version-history":[{"count":5,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1138\/revisions"}],"predecessor-version":[{"id":1177,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1138\/revisions\/1177"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}