answersLogoWhite

0

You can use recursion:

void printNum(int i)
{ if(i <= 100)
{ printf("%d\n", i);
printNum(i + 1); } }




int main()
{
printNum(1);

return 0;
}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you print 1 to 100 without using loop in php?

The best way to print the numbers 1 to 100 in PHP without using a loop is with the following code: echo implode("&lt;br&gt;", range(1,100)); You can replace the &lt;br&gt; with anything that you want to separate the numbers, such as dashes. I used a line-break in the example.


How do you print numbers 1 to 100 and 100 to 1 without using loop in C?

printf ("%s\n", "1, 2, 3, 4, 5, 6, ..., 98, 99, 100"); printf ("%s\n", "100, 99, 98, 97, ..., 3, 2, 1");


What does a for next loop do?

A for loop is typically used to implement a counted loop: for x=0 to 100 step 1 print x next x


Program to print wvwn numbers from 1 to 100 in gw basic?

In GW-BASIC, you can print even numbers from 1 to 100 using a simple loop. Here’s a sample code: FOR i = 1 TO 100 IF i MOD 2 = 0 THEN PRINT i NEXT i This program iterates through numbers 1 to 100 and prints each number if it is even (i.e., divisible by 2).


Write an algorithm or draw a flowchart to display numbers from 100 down to 10?

n=100 loop until n = 9 print n n = n -1 end loop


How do you print 1 to 100 in c without using loop condition?

If you mean you cannot use a for loop, then use a while loop: int i=0 while( i++ &lt; 100 ) std::cout &lt;&lt; i &lt;&lt; " "; std::cout &lt;&lt; std::endl; Or a do-while loop: int i=0; do std::cout &lt;&lt; ++i &lt;&lt; " "; while( i&lt;100 ); std::cout &lt;&lt; std::endl; If these are not allowed either, use a procedural loop: int i=0; again: std::cout &lt;&lt; ++i &lt;&lt; " "; if( i&lt;100 ) goto again; std::cout &lt;&lt; std::endl; If even that is not allowed, then the only option is to hard-wire: std::cout &lt;&lt; 1 &lt;&lt; " " &lt;&lt; 2 &lt;&lt; " " &lt;&lt; [etc] &lt;&lt; 99 &lt;&lt; " " &lt;&lt; 100 &lt;&lt; std::endl; It does seem a pointless exercise when a for loop exists specifically for counting iterations like this: for( int i=1; i&lt;=100; ++i ) std::cout &lt;&lt; i &lt;&lt; " "; std::cout &lt;&lt; std::endl;


Pseudocode to print your name hundred time?

Here's a simple pseudocode to print your name a hundred times: FOR i FROM 1 TO 100 PRINT &quot;Your Name&quot; END FOR Replace &quot;Your Name&quot; with your actual name. This loop iterates 100 times, printing your name in each iteration.


Where will you use loops?

A loop is used in programming to repeat a set of commands in the program when a task is a repetitive one. It means less code has to be written and it makes a computer more flexible. If you wanted to do something like print all the numbers from 1 to 100 on the screen, you could do it with a loop. One way is to do 100 separate commands to print each number which is a long way. That will make your program quite long. With a loop you can use the command to print a number and tell it to do that command 100 times and increase the number being printed by 1 every time the command is run.


Draw a flowchart of for loop of number between 1 and 100?

start n=1,0 print n n&gt;=99,100 yes end no n=n+2 back to print step


How can print prime numbers in between 1-100 but not adjust 40-50 in php language?

Use a counted loop in the closed range [1:100]. If the count is in the closed range [40:50], print the number. For all other numbers outwith this range, only print the number if it is prime.


How do you write print 1 to 100 using recursion only?

recu


How to draw Flowchart to print prime numbers from 1 to 100 using while loop in c language?

Oh, dude, drawing a flowchart for printing prime numbers from 1 to 100 using a while loop in C? That's like asking me to explain quantum physics while juggling flaming torches. But hey, you basically start with a start symbol, then draw a decision box to check if a number is prime, and loop back until you reach 100. Just remember to add some arrows and shapes, and you're good to go!

Trending Questions
Can you park across a drop kerb? The genetic material of which kind of cells is included in a single circular molecule of DNA devoid of any histone proteins? When a function is used as an argument in another function? How much current will a 15 hp single phase 220 volt fan motor draw? How do you calculate 3 phase kva to kw? How much do bio engineers make? How would high sugar rye grass be produced by genetic engineering? How do you write he is engineer in french? What is the easiest rsps source to code? What is the header file for using graphics in c plus plus? How do you lubricate a rubber or silicone piston sliding inside a cylindrical transparent acryl pipe the piston has an outer diameter of 3mm and the pipe has an inner diameter of 3mm for air pressu? How did the steel windmill change lives on the prairie? Is Variable declaration in event handlers begin with keyboard declar? 4 How does the type and direction of stress applied affect the selection of the material and the cross section? How would you describe a metal that has a yield strength and tensile strength that are the same? What is the total resistance of a series circuit that has 12 volts (12 V) applied and has 0.5 amps of? What command is used to exit from the middle of a loop in Scilab? Why is top-down testing not an effective strategy for testing object oriented system? When can you accelerate even when your speed doesn't change? If you read the line voltage supplied to an appliance you should connect the voltmeter?