{"id":27,"date":"2016-10-09T08:19:06","date_gmt":"2016-10-09T08:19:06","guid":{"rendered":"http:\/\/codeinsightacademy.com\/blog\/?p=27"},"modified":"2025-08-07T09:28:28","modified_gmt":"2025-08-07T09:28:28","slug":"loops-programs","status":"publish","type":"post","link":"https:\/\/codeinsightacademy.com\/blog\/c-programming\/loops-programs\/","title":{"rendered":"Loops Programs"},"content":{"rendered":"\n<h1>EXACT OUTPUT IS OPTIONAL FOR PYTHON AND JAVASCRIPT<\/h1>\n\n\n<p><strong>WAP to read a number and print all numbers from 1 to that number<\/strong><\/p>\n<pre><code class=\"language-txt\">Input: Enter a number: 5\nOutput:\n1\n2\n3\n4\n5\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to read number and print all even numbers from 1 to that number<\/strong><\/p>\n<pre><code class=\"language-txt\">Input: Enter a number: 5\nOutput:\n2\n4\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to print all numbers from 1 to 10 using while, for, and do-while loop<\/strong><\/p>\n<hr \/>\n<p><strong>WAP to read a number and find sum of all numbers from 1 to that number<\/strong><\/p>\n<pre><code class=\"language-txt\">Input: Enter a number: 5\nOutput: 1 + 2 + 3 + 4 + 5 = 15\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to read a number and find factorial of that number<\/strong><\/p>\n<pre><code class=\"language-txt\">Input: Enter a number: 5\nOutput: 1 * 2 * 3 * 4 * 5 = 120\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to read a number and check if it is a prime number or not<\/strong><\/p>\n<pre><code class=\"language-txt\">Input: Enter a number: 5\nOutput: 5 is a prime number\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to print all prime numbers in range from 1 to 100<\/strong><\/p>\n<pre><code class=\"language-txt\">Output:\n2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n31, 37, 41, 43, 47, 53, 59, 61, 67,\n71, 73, 79, 83, 89, 97\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to print first 10 Fibonacci numbers<\/strong><\/p>\n<pre><code class=\"language-txt\">Output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to print table of number in following format using 1 for loop<\/strong><\/p>\n<pre><code class=\"language-txt\">Input: Enter a number: 5\nOutput:\n5 * 1 = 5     5 * 10 = 50\n5 * 2 = 10    5 * 9 = 45\n5 * 3 = 15    5 * 8 = 40\n5 * 4 = 20    5 * 7 = 35\n5 * 5 = 25    5 * 6 = 30\n5 * 6 = 30    5 * 5 = 25\n5 * 7 = 35    5 * 4 = 20\n5 * 8 = 40    5 * 3 = 15\n5 * 9 = 45    5 * 2 = 10\n5 * 10 = 50   5 * 1 = 5\n<\/code><\/pre>\n<hr \/>\n<p><strong>WAP to create random jackpot number and take input from user to guess the number<\/strong><\/p>\n<ul>\n<li>\n<p>Based on level, the attempt to guess the number should change:<\/p>\n<ul>\n<li>\n<p>Easy &#8211; 20 attempts<\/p>\n<\/li>\n<li>\n<p>Medium &#8211; 10 attempts<\/p>\n<\/li>\n<li>\n<p>Difficult &#8211; 5 attempts<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><strong>WAP to execute Fizz Buzz Problem \/ Print number 1 to 100<\/strong><\/p>\n<ul>\n<li>\n<p>If number is divisible by 3 then print Fizz<\/p>\n<\/li>\n<li>\n<p>If number is divisible by 5 then print Buzz<\/p>\n<\/li>\n<li>\n<p>If number is divisible by both 3 and 5 then print Fizz Buzz<\/p>\n<\/li>\n<\/ul>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EXACT OUTPUT IS OPTIONAL FOR PYTHON AND JAVASCRIPT WAP to read a number and print all numbers from 1 to that number Input: Enter a number: 5 Output: 1 2 3 4 5 WAP to read number and print all even numbers from 1 to that number Input: Enter a number: 5 Output: 2 4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,3,18,4,9],"tags":[],"_links":{"self":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/27"}],"collection":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":47,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":2856,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions\/2856"}],"wp:attachment":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}