{"id":362,"date":"2021-10-18T06:45:08","date_gmt":"2021-10-18T06:45:08","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=362"},"modified":"2021-10-21T07:54:01","modified_gmt":"2021-10-21T07:54:01","slug":"c-program-to-find-largest-smallest-among-n-numbers","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/c-program-to-find-largest-smallest-among-n-numbers\/","title":{"rendered":"C Program to Find Largest &#038; Smallest among N Numbers"},"content":{"rendered":"\n<p>There are many ways to identify largest or smallest number from user input. Here we are using for loop.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>\/\/ Program to find smallest and largest number from user input.\n\n#include&lt;stdio.h&gt;\nvoid main()\n{\n    int large,small,no,range,i;\n    printf (&quot;\\n\\tFrom how many numbers you want to identify smallest and largest\\t&quot;);\n    scanf (&quot;%d&quot;, &range);\n    printf (&quot;\\n\\tEnter  number 1==&gt;&quot;);\n    scanf (&quot;%d&quot;, &no);\n    large = no;\n    small=no;\n    for (i=1; i&lt;= range -1 ; i++)\n    {\n        printf (&quot;\\n\\t Enter number %d ==&gt; &quot;,i+1);\n        scanf (&quot;%d&quot;,&no);\n        if (no &gt;= large)\n        large = no;\n        if (no &lt;= small)\n        small = no;\n    }\/\/end of For loop\n    printf (&quot;\\n\\t The largest number is %d&quot;, large);\n    printf (&quot;\\n\\t The smallest number is %d&quot;, small);\n\n}<\/code><\/pre><\/div>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> From how many numbers you want to identify smallest and largest 6\n\n        Enter  number 1==>11\n\n         Enter number 2 ==> 11\n\n         Enter number 3 ==> 22\n\n         Enter number 4 ==> 22\n\n         Enter number 5 ==> 33\n\n         Enter number 6 ==> 44\n\n         The largest number is 44\n\n         The smallest number is 11<\/code><\/pre>\n\n\n\n<p>We can write this program using various loop and logic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many ways to identify largest or smallest number from user input. Here we are using for loop. Output We can write this program using various loop and logic.<\/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-362","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":"There are many ways to identify largest or smallest number from user input. Here we are using for loop. Output We can write this program using various loop and logic.","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/362","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=362"}],"version-history":[{"count":12,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/362\/revisions"}],"predecessor-version":[{"id":406,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/362\/revisions\/406"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}