answersLogoWhite

0

Move the print out requesting the user to enter an integer outside of the for loop and it will only print once instead of each time around the loop.

You'll need a way to save the even and odd numbers that you detect in the loop.

One way is to have separate arrays to hold the even and the odd numbers as you go around the loop. Then at the end of the loop you can have more loops to print the contents of one array and then the contents of the other array.

Another way is to concatenate the number onto separate Strings (even and odd) to be displayed after the data gathering loop.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is odd loop in 'C' program?

odd loop means at least the loop execute once.


How do you use even and odd numbers for loop and if condition with variable please no use int?

how to use even and odd number with for loop and if condition plz dont use "int"..


What is the program to print odd number using for next loop in GE BASIC?

In GE BASIC, you can print odd numbers using a FOR-NEXT loop by specifying a starting point and incrementing by 2. Here’s a simple example: FOR I = 1 TO 99 STEP 2 PRINT I NEXT I This will print all odd numbers from 1 to 99. The STEP 2 ensures the loop only increments by 2, thereby producing only odd numbers.


How can you write a c program using while loop that will print first ten odd numbers?

#include<stdio.h> int main () { int odd=1; int count=0; while (count++<10) { printf (%d\n", odd); odd+=2; } return 0; }


Write a JavaScript for loop that will iterate from 0 to 15. For each iteration it will check if the current number is odd or even and display a message to Sample Output 0 is even 1 is odd 2 is even?

You can use the following JavaScript code to achieve this: for (let i = 0; i <= 15; i++) { let message = `${i} is ${i % 2 === 0 ? 'even' : 'odd'}`; console.log(message); } This loop iterates from 0 to 15, checks if the current number i is even or odd using the modulus operator, and logs the appropriate message to the console.


Display odd number using for loop?

It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i < 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }


What are the release dates for Loop Loop Loop Loop - 2014?

Loop Loop Loop Loop - 2014 was released on: USA: 15 February 2014


How do you write a loop that sums the odd numbers from 1 to 100 in Java format?

Like this: int sum = 0; for(int i = 1; i<=100; i+=2){ sum+=i; } The "for" loop starts the counter i at 1, continues while it is less than or equal to 100, and increments it by 2 at a time.


What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


The while loop is a type of loop?

Is loop


What is loop logic structure?

I believe it is: Loop condition Loop actions And how the loop breaks


When was Loop-the-Loop - roller coster - created?

Loop-the-Loop - roller coster - was created in 1901.