Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2012 00:45
Show Gist options
  • Save anonymous/3615358 to your computer and use it in GitHub Desktop.
Save anonymous/3615358 to your computer and use it in GitHub Desktop.
minmax
//This code works. Put in the commented out statements, doesn't work anymore.
#include<stdio.h>
#include<limits.h>
#include<ctype.h>
int main()
{
int number=0;
int min=INT_MAX;
int max=-1;
printf("Enter any set of numbers: ");
while(EOF!=scanf("%d",&number)) //Loop finding max and min.
{
//if(isdigit(number)) //Loop checking if it is digit
{
if(number>max)
{
max=number;
}
else if(number<min)
{
min=number;
}
}
//else
//{
//printf("This is not a digit");
//return 0;
//}
};
printf("The max value is %d and the minimum value is %d \n",max,min);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment