# Thread: Infinite Numbers C Program

1. ## Infinite Numbers C Program

Hello,

Very new to programming and I am having trouble with an assignment
I need to be able to have the user enter an infinite amount of numbers and when finished, display the highest and lowest number, number of . even numbers and average of odd numbers entered. Thank you!

Code:
``` :
#include <stdio.h>
#include <stdlib.h>

int main() {

int userNum=0, count=0, highNum=0, lowNum=0, evenNum=0, oddNum=0;

printf("Enter a number greater than 0: (Enter -1 to stop) \n");
scanf("%i", &userNum);

while (userNum != -1){
if (userNum > lowNum)
highNum = userNum;
if (userNum > highNum)
lowNum = userNum;
if (userNum%2 == 0)
evenNum = userNum;
if (userNum%2 != 0)
oddNum = userNum;
count = count + 1;
printf("Enter a number:(-1 to stop)\n");
scanf("%i", &userNum);
}

if (userNum%2 == 0)
evenNum = userNum;
if (userNum%2 != 0)
oddNum = userNum;

printf("The highest number entered is: %i \n", highNum);
printf("The lowest number entered is: %i \n", lowNum);
printf("The number of even numbers entered is: %i \n", evenNum);
printf("The average of odd numbers entered is: %i \n", oddNum);
}``` 2. You mixed up the highNum and lowNum assignments.

You're supposed to count the even numbers, not track the most recent even number.

You need to remember to use braces when needed. If not, always use braces. Popular pages Recent additions entered, number, numbers, usernum%2, usernum; 