int main()
{ int another = 1;
while(another = 1)
printf("Hello\n")'
printf("Press 1 to recieve another greeting or zero to terminate.\n");
scanf("%f",&another);
}
system("pause");
return(0);
it keeps repeating even if I press 0.!?!?
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
include <stdio.h>
int main()
{ int another = 1;
while(another = 1)
printf("Hello\n")'
printf("Press 1 to recieve another greeting or zero to terminate.\n");
scanf("%f",&another);
}
system("pause");
return(0);
it keeps repeating even if I press 0.!?!?
Thanks!
What is a "definite while loop"?
definitely going to loop forever?
;)
Wayne
%f is to read floats
%i-integer
%d-decimal integer
http://cplusplus.com/reference/clibrary/cstdio/scanf.html
Note also that
while (another = 1)
Is probably NOT doing what you think it is. = is the assignment
operator, not the comparison operator, which is ==
Your line of code is putting 1 in the variable another, and if it does it successfully, returns true
Consider what this does instead:
while (another == 1)
Don't feel too bad, this is probably my most often done mistake.
Makes me mis Ada, where = is the comparison operator, and := is the assignment operator.
Wayne