{"id":150,"date":"2021-09-28T16:07:33","date_gmt":"2021-09-28T16:07:33","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=150"},"modified":"2021-10-11T11:49:15","modified_gmt":"2021-10-11T11:49:15","slug":"c-program-to-find-even-odd-numbers-and-their-sum-and-average","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/c-program-to-find-even-odd-numbers-and-their-sum-and-average\/","title":{"rendered":"C Program to find even ,odd numbers and their sum and average"},"content":{"rendered":"\n<p>Below program will accept the range for example 62 to 70. Program will count all even and odd numbers from range 62 to 70 and perform sum of even and odd numbers respectively. It also provide average of odd and even numbers.<\/p>\n\n\n\n<div style=\"height:24px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Program Name: Accept Range from user and then find even odd numbers with sum and average respectively.\n#include&lt;stdio.h&gt;\n \nvoid main()\n{\n int startNum=0,endNum=0,i=0,eNoCnt=0,oNoCnt=0,eSum=0,oSum=0;\n \n printf(\"\\n\\t Provide Range of number to identify even number as requested for e.g 56 90\");\n printf(\"\\n\\n\\n\\t Please provide Range\\t\");\n scanf(\"%d\", &amp;startNum);\n scanf(\"%d\", &amp;endNum);\n\n for(i = startNum; i &lt; endNum; i ++)\n {\n   if(i % 2 == 0)\n   {\n     eNoCnt++;\n     eSum=eSum+i;\n   }\n   else\n   {\n     oNoCnt++;\n     oSum=oSum+i;\n   }\n }\n  \n printf(\"\\n\\t Total Number of Even Numbers are = %d \", eNoCnt);\n printf(\"\\n\\t Total of Even number is %d\",eSum);\n printf(\"\\n\\t Average of Even Number is %d\",eSum\/eNoCnt);\n printf(\"\\n\\n\\t Total Number of Odd Numbers are = %d \", oNoCnt);\n printf(\"\\n\\t Total of Odd number is %d\",oSum);\n printf(\"\\n\\t Average of Odd Number is %d\",oSum\/oNoCnt);\n}<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>Please provide Range   1\n500\n\n         Total Number of Even Numbers are = 249 \n         Total of Even number is 62250\n         Average of Even Number is 250\n\n         Total Number of Odd Numbers are = 250 \n         Total of Odd number is 62500\n         Average of Odd Number is 250<\/code><\/pre>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Below program will accept the range for example 62 to 70. Program will count all even and odd numbers from range 62 to 70 and perform sum of even and odd numbers respectively. It also provide average of odd and even numbers. Output<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-150","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":0,"uagb_excerpt":"Below program will accept the range for example 62 to 70. Program will count all even and odd numbers from range 62 to 70 and perform sum of even and odd numbers respectively. It also provide average of odd and even numbers. Output","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/150","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=150"}],"version-history":[{"count":2,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/150\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}