This program is supposed to give you back the smallest integer. See you put in a number, and that will specify how many you will be allowed to put in before the program decides the smallest. My program compiles and runs, but it does not give me the right value back all the time. Try it and help, please. thanks
This isn't giving me the right return, it gives me wierd outputs, it doesn't give me the smallest, I think my counter may be wrong
-------------------------------
Code:
#include <stdio.h>
int main()
{
int firstValue=0, currentNumber, counter=0, smallestNumber;
printf("Please enter a positive integer value. the first value you enter is the number of integers you will be allowed to enter further.\n");
scanf("%d", &firstValue);
while ( counter <= firstValue )
{
printf( "Enter integer: " );
scanf( "%d", ¤tNumber );
smallestNumber = firstValue;
if ( smallestNumber > currentNumber )
smallestNumber = currentNumber;
counter= counter + 1;
}
/*termination phase*/
printf( "The lowest integer value you put in is %d/n", smallestNumber );
return 0;
}
tagged by Salem