{"id":1158,"date":"2021-12-27T09:41:34","date_gmt":"2021-12-27T09:41:34","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=1158"},"modified":"2022-01-18T09:17:17","modified_gmt":"2022-01-18T09:17:17","slug":"how-to-print-number-series-using-different-loops","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/how-to-print-number-series-using-different-loops\/","title":{"rendered":"How to print number series using different loops in C"},"content":{"rendered":"\n<p>This C Language program prints numbers from 1 to 5 using for loop, do-while loop, and while loop in easy steps.<\/p>\n\n\n\n<p>Change the counter value in case the user wants to print n numbers.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>#include&lt;stdio.h&gt;  \nint main(){    \nint i=1,j=1,k=1;      \n\/\/print number series using do while loop\ndo{    \nprintf(&quot;%d \\t&quot;,i);    \ni++;    \n}while(i&lt;=5);   \nprintf(&quot;\\n&quot;);\n\n\/\/print number series using while loop\n\nwhile(j&lt;=5)\n{\n    printf(&quot;%d\\t&quot;,j);\n    j++;\n}\n\/\/print number series using for loop\nprintf(&quot;\\n&quot;);\nfor(int k=1;k&lt;=5;k++)\n  printf(&quot;%d\\t&quot;,k);\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>1 \t2 \t3 \t4 \t5 \t\n1\t2\t3\t4\t5\t\n1\t2\t3\t4\t5<\/code><\/pre><\/div>\n\n\n\n<p>By changing variable values one can print n number series in C language using three different loops.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This C Language program prints numbers from 1 to 5 using for loop, do-while loop, and while loop in easy steps. Change the counter value in case the user wants to print n numbers. Output By changing variable values one can print n number series in C language using three different loops.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-1158","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":"This C Language program prints numbers from 1 to 5 using for loop, do-while loop, and while loop in easy steps. Change the counter value in case the user wants to print n numbers. Output By changing variable values one can print n number series in C language using three different loops.","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/1158","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=1158"}],"version-history":[{"count":5,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":1322,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/1158\/revisions\/1322"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}