I need help. The program requires the user to enter 10 integers then print the total no. of even integer,highest even integer, lowest even integer then total no. of odd integer,highest odd integer, lowest odd integer

I already got the total no. of even integer and total no. of odd integer. But I don't know how will i get the highest even integer, lowest even integer and highest odd integer, lowest odd integer.

can anybody share some ideas?
int lowestEven = some high number;
int highestEven = 0;
int lowestOdd = some high number;
int highestOdd = 0;
While reading input, put lowestEven and highestEven = 1st even integer obtained. Put lowestOdd & highestOdd = 1st odd integer obtained.
Then compare for each subsequent integer and set the lowest and highest values whenever you encounter "lower than lowest" or "higher than highest" integers.
would be easier to make suggestions if you posted your code.

The trick I think is the first time you run the program, it must assign the first number to highest and lowest, else, you will be checking to see if the number is lower than zero, which of course it never will be.

After, the first number, When you determine if the number is even or odd, check to see if the current number is larger or smaller than the current highest and lowest.

Another option is to define your int values like. Then you wont' have to check to see if it's the first number, it should always be lower than the max value.

int higheven=0;
int loweven=2147483647;
int highodd=0;
int lowodd=2147483647;
Last edited on
Topic archived. No new replies allowed.