Hi,
I have written the program below and the compiler is not giving any error message and when I run it, the first request for an enter is almost always followed by strange numbers,which I don't know where they come from
#include<stdio.h>
int main()
{
int value;
int inputs;
int number_values;
int smallest;
printf("Please enter the number of value: %d\n", number_values);
scanf("%d", &number_values);
/*Begining of for cicle*/
for(inputs = 1; inputs <= number_values; ++inputs)
{
printf("Please enter the next number: %d\n", value);
scanf("%d", &value);
/*Begining of if cicle*/
if(smallest> value)
{
smallest = value;
}
/*End of if cicle*/
printf("The smallest is: %d\n", smallest);
}/*End of for cicle*/
return 0;
}
The second question is about something related to how the computer works out the solution. After all the program is ok, but in depth there is something strange, namely
as you can see, the variable "smallest" has no value at the beginning of the program, clearly,and after the first "value"entered, logically, the program should skip the following "if " since there is no value for comparing, but strangely this is not the case. It seems that the variable "smallest" got some value, but I do not understand which one, and where it comes from.
Is there anyone able to help me???
Thank You very much!!
Bye Bye!!!