Program to ask a user for supplying n different integers and countthe total number of even and odd values among them
Question
Program to ask a user for supplying n different integers and countthe total number of even and odd values among them
Solution
Sure, here is a simple program that does what you asked for:
# Ask the user for the number of integers
n = int(input("Enter the number of integers: "))
# Initialize counters for even and odd numbers
even_count = 0
odd_count = 0
# Ask the user for n integers
for i in range(n):
num = int(input("Enter an integer: "))
# Check if the number is even or odd and update the counters
if num % 2 == 0:
even_count
Similar Questions
Write a C++ program to find the sum of even and odd n natural numbers
Write a vb.net program that uses a sub procedure to calculate and sum of all even numbers between 1 and n where n is supplied by the user
Complete the function count_odd_even() , which receives number of elements and array as input. Function should count number of even numbers and odd numbers in the array and print it.Input Format:No Need to read any input, as it is predefined.Output Format:Print the count of odd and even as: Odd = ODD_COUNTEven = EVEN_COUNTConstraints:1<=size<=10^9 1<=arr[ind]<=10^15Sample Input 1:1047 41 87 88 95 46 35 66 63 93Sample Output 1:Odd = 7Even = 3Sample Input 2:81 2 3 4 5 6 7 8Sample Output 2:Odd = 4Even = 4
Write a program to accept an integer N and print the sum of first N odd numbersInput Format:An integer range is given inputOutput Format:Print only calculated sum.Constraints:1 <= N <= 10^16 Sample Input 1:2Sample Output 1:4Sample Input 2:10Sample Output 2:100
1. Write the program to enter integer elements from user in singly linked list. User can enter both andeven values.2. Your program then search for even and odd values and make a separate sorted singly linked list foreven and odd values.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.