+ 2
Write a program to display only even numbers number and ignoring the odd numbers from a range given by the user.
programs
8 ответов
+ 4
import java.util.Scanner;
public class Number {
public static void main(String[] args) {
int startFrom;
int finishTo;
Scanner keyboard=new Scanner(System.in);
do {
System.out.print("Insert the range (start from) :");
startFrom=keyboard.nextInt(); }
while(startFrom<0);
do {
System.out.print("Insert the range (finish to) :");
finishTo=keyboard.nextInt(); }
while(finishTo<startFrom);
for(int i=startFrom; i<=finishTo; i++) {
if(i%2==0)
System.out.println(i);
}
}
+ 1
thanks akshata
0
in loop. .for odd numbers use continue keyword to skip these loops and print even numbers.
0
can you do sir
0
do you use whatsapp
0
if I remember correctly every binary instruction has a parity bit that is on an 8-bit instruction of Zeros and one's 7 of the instruction added to the parity bit must be an even number so if an odd number is detected the computer knows there is an error without needing to understand what an error is so the first 7 digits are the instruction and if they add to 47 the parity bit would be one to make 48 but if they add to 48 then the parity bits would be 0 that's how computer checks for errors please correct me if I'm wrong