Question: Write a program that reads the inputs repeatedly using a while loop. The code should skip the even numbers and print only the odd numbers.
Write a program that reads the inputs repeatedly using a while loop. The code should skip the even numbers and print only the odd numbers. Inputs are always valid.
Note:
It should accept only int input
It can read any int input but print only the odd values of input
Output:
Input
Output:
Write a program to generate a random number between and The program should use a while loop to determine if the number is prime or not. You
Note: can not use a predefined set of prime numbers.
Prime numbers are the numbers which has only two factor and then the number itself
So to find whether a number is prime number or not we have to find the factors of the number:
Here is the steps to find the factors of the number.
Find all the numbers less than or equal to the given number
Divide the given number by each of the numbers.
The divisors that give the remainder to be are the factors of the number
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
