Main link : https://www.urionlinejudge.com.br/judge/en/problems/view/1065
URI Online Judge | 1065
Even Between five Numbers
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Make a program that reads five integer values. Count how many of these values are even and print this information like the following example.
Input
The input will be 5 integer values.
Output
Print a message like the following example with all letters in lowercase, indicating how many even numbers were typed.
Input Sample | Output Sample |
7 -5 6 -4 12 | 3 valores pares |
URI Online Judge Solution 1065 in C
#include<stdio.h>
int main(){
int i, n, even = 0;
for(i =1; i <= 5; i++){
scanf("%f", &n);
if(n % 2 == 0){
even += 1;
}
}
printf("%d valores pares\n", even);
}
URI Online Judge Solution 1065 in Java
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner input =new Scanner(System.in);
int i, n, even = 0;
for(i =1; i <= 5; i++){
n = input.nextInt();
if(n % 2 == 0){
even += 1;
}
}
System.out.printf("%d valores pares\n", even);
}
}
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks