{"id":140,"date":"2021-09-27T08:56:22","date_gmt":"2021-09-27T08:56:22","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=140"},"modified":"2021-11-05T11:08:28","modified_gmt":"2021-11-05T11:08:28","slug":"c-program-to-identify-even-odd-numbers-from-user-input","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/c-program-to-identify-even-odd-numbers-from-user-input\/","title":{"rendered":"C Program to Identify Even Odd numbers from user input."},"content":{"rendered":"\n<p>Below program will first accept total number which user want to enter. Then user has to enter numbers one by one.<\/p>\n\n\n\n<p>Program will identify even and Odd numbers and store their total count in variable.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Program Name: Accept n numbers from user and then identify even or odd Numbers\n#include&lt;stdio.h&gt;\n \nvoid main()\n{\n int totalNum, i, ary&#91;100];\n int eNoCnt = 0, oNoCnt = 0;\n \n printf(\"\\n\\t Enter the Size of an Array (total numbers)  :  \\t\");\n scanf(\"%d\", &amp;totalNum);\n \n printf(\"\\n\\t Enter the Numbers to identify even numbers\\t\");\n for(i = 0; i &lt; totalNum; i++)\n {\n   scanf(\"%d\", &amp;ary&#91;i]);\n }\n  \n for(i = 0; i &lt; totalNum; i ++)\n {\n   if(ary&#91;i] % 2 == 0)\n   {\n     eNoCnt++;\n   }\n   else\n   {\n     oNoCnt++;\n   }\n }\n  \n printf(\"\\n\\t Total Number of Even Numbers are = %d \", eNoCnt);\n printf(\"\\n\\t Total Number of Odd Numbers are = %d \", oNoCnt);\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n\t Enter the Size of an Array (total numbers)  :  \t6\n\n\n\n\t Enter the Numbers to identify even numbers\t1\n\n2\n\n3\n\n4\n\n5\n\n6\n\n\n\n\t Total Number of Even Numbers are = 3 \n\n\t Total Number of Odd Numbers are = 3 \n\n<\/code><\/pre>\n\n\n\n\n\n<h2 class=\"wp-block-heading\" id=\"printOddNumber\">Program to print Odd Numbers till user input<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>\/\/ Program to print odd numbers from 1 to n\n#include &lt;stdio.h&gt;\nint main() {\n    int range;\n    printf(&quot;Enter range of number to print odd numbers&quot;);\n    scanf(&quot;%d&quot;,&range);\n      printf(&quot;Odd Numbers from 1 to %d are \\n&quot;,range);\n    for(int i =1;i&lt;=range;i++)\n    {\n        if (i%2 != 0)\n        printf(&quot;\\t%d&quot;,i);\n    }\n    return 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-plain\"><code>Enter range of number to print odd numbers   15\nOdd Numbers from 1 to 15 are \n\t1\t3\t5\t7\t9\t11\t13\t15<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Program to Print Even Numbers till User Input<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>\/\/ Program to print even numbers from 1 to n\n#include &lt;stdio.h&gt;\nint main() {\n    int range;\n    printf(&quot;Enter range of number to print even numbers  &quot;);\n    scanf(&quot;%d&quot;,&range);\n      printf(&quot;Even numbers from  1 to %d are \\n&quot;,range);\n    for(int i =1;i&lt;=range;i++)\n    {\n        if (i%2 ==  0)\n        printf(&quot;\\t%d&quot;,i);\n    }\n    return 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-plain\"><code>Enter range of number to print even numbers  15\nEven numbers from  1 to 15 are \n\t2\t4\t6\t8\t10\t12\t14<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Below program will first accept total number which user want to enter. Then user has to enter numbers one by one. Program will identify even and Odd numbers and store their total count in variable. Program to print Odd Numbers till user input Output Program to Print Even Numbers till User Input 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-140","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 first accept total number which user want to enter. Then user has to enter numbers one by one. Program will identify even and Odd numbers and store their total count in variable. Program to print Odd Numbers till user input Output Program to Print Even Numbers till User Input Output","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/140","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=140"}],"version-history":[{"count":9,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":916,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/140\/revisions\/916"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}