I successfully completed this problem with a while loop, but I was wondering if I could do it with a for loop. Why is the following not working?
Code:#include <stdio.h> #include <stdlib.h> #define BIL 1000000000 int main(void) { float num_one; float num_two; float math_answer; int loop_test; int i; printf("Give me two numbers: "); for(i = scanf("%f%f",&num_one, &num_two); (-BIL<=num_one<=BIL) && (-BIL<=num_two<=BIL); scanf("%f%f",&num_one, &num_two)); { math_answer = (num_one-num_two)/(num_one*num_two); printf("Here is the (first # - the second #) divided by their product: %f\n", math_answer); printf("Give me two more numbers or q to quit: "); } printf("Quitting :)"); return EXIT_SUCCESS; }



LinkBack URL
About LinkBacks



