C++ assignment
Write a program that reads a sequence of integers and prints the following:
1. The number of odd and even numbers of inputs Use a sentinel value to signal the end of inputs.
If the sentinel value is the first you enter, give a message “NO input is entered!”. Input Validation: Do not accept a negative number.
#include <iostream> using namespace std; int main() { int n; cout<<"Enter number: "; cin>>n; if(n==0){ cout<<"NO input is entered!"; } else{ int oddCount = 0, evenCount = 0; while(n!=0){ if(n>0){ if(n%2==0){ evenCount++; } else{ oddCount++; } } cout<<"Enter number: "; cin>>n; } cout<<"Even count = "<<evenCount<<endl; cout<<"Odd count = "<<oddCount<<endl; } return 0; }
C++ assignment Write a program that reads a sequence of integers and prints the following: 1....
C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...
C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
Write a program that reads a set of integers and then finds and prints the sum of the even and odd integers
In Python 3 - Write a program that reads a sequence of integer inputs from the user. When the user is finished entering the integers, they will enter a 'q'. There is no need to check if the entry is a valid integer. All integers in the test data (input) will be between -255 and 255. The program should then print: The smallest and largest of the inputs. The number of even and odd inputs (0 should be considered even)...
Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and stores them in an array, and then calls the following two functions and prints the results in a readable format. The two functions are: smallestLargest: computes the smallest and the largest values in the array. oddEven: computes the number of even integers and the number of odd integers.
JAVA. Write a program that reads in a series of positive integers and prints out the maximum value entered. The user will indicate they are finished entering numbers by entering zero or a negative integer.
For Java Write a program that reads a sequence of integer inputs all on one line and prints: 1.)The smallest and largest of the inputs 2.)The number of odd and even inputs 3.)Cumulative totals. If the input is 1 7 2 9, the program prints 1 8 10 19. 4.)All adjacent duplicates. If the input is 1 3 3 4 5 5 6 6 6 2, the output is 3 5 6.
Write a C program that reads a list of positive integers from a file named "input.txt." and count number of odd integers and even integers and prints the results to another file called "results.txt". Please submit both the input and results files along with the c program.
In Java* Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array. Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...