{"id":1063,"date":"2021-12-06T08:44:23","date_gmt":"2021-12-06T08:44:23","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=1063"},"modified":"2021-12-21T10:57:58","modified_gmt":"2021-12-21T10:57:58","slug":"c-program-to-calculate-the-average-of-user-input-using-array","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/c-program-to-calculate-the-average-of-user-input-using-array\/","title":{"rendered":"C program to find the average of user input using array"},"content":{"rendered":"\n<p>This program accepts users to input up to any number and stores it Array. Then calculate the average of stored numbers by calculating the total or sum and then dividing it by a number of inputs.<\/p>\n\n\n\n<p>This C program uses an array to store scores or numbers in a declared array.<\/p>\n\n\n\n<p>In for loop program ask the user to input numbers and store them in the array.<\/p>\n\n\n\n<p>Once the loop is over code calculate the average.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>\/\/average of user input numbers or scores using array\n#include &lt;stdio.h&gt;\nint main() {\nint arrayVal[100],cntScore,Total=0,i; \nfloat average;\nprintf(&quot;Enter No of Scores to Calculate Average\\t&quot;);\nscanf(&quot;%d&quot;,&cntScore);\nfor(i=0;i&lt;cntScore;i++)\n{\n    printf(&quot;Enter %d Score&quot;,i+1);\n    scanf(&quot;%d&quot;,&arrayVal[i]);\n    Total = Total + arrayVal[i];\n}\naverage = (float)Total\/cntScore;\nprintf(&quot;Average of %d Score is %.2f&quot;,cntScore,average);\nreturn 0;\n}<\/code><\/pre><\/div>\n\n\n\n<p>Output<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>Enter No of Scores to Calculate Average\t3\nEnter 1 Score\t11\nEnter 2 Score\t22\nEnter 3 Score\t33\nAverage of 3 Score is 22.00<\/code><\/pre><\/div>\n\n\n\n<p>Code is available to download from GitHub<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/malpuresuhas\/Github_C_Program\/blob\/master\/averageNumbers.c\">https:\/\/github.com\/malpuresuhas\/Github_C_Program\/blob\/master\/averageNumbers.c<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This program accepts users to input up to any number and stores it Array. Then calculate the average of stored numbers by calculating the total or sum and then dividing it by a number of inputs. This C program uses an array to store scores or numbers in a declared array. In for loop program [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-1063","post","type-post","status-publish","format-standard","hentry","category-c-language"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":6,"uagb_excerpt":"This program accepts users to input up to any number and stores it Array. Then calculate the average of stored numbers by calculating the total or sum and then dividing it by a number of inputs. This C program uses an array to store scores or numbers in a declared array. In for loop program&hellip;","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/1063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=1063"}],"version-history":[{"count":3,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/1063\/revisions"}],"predecessor-version":[{"id":1153,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/1063\/revisions\/1153"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=1063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=1063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=1063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}