Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int main(int argc, char *argv[])
- {
- int i; // Not initialised at start up.
- float r=0.0; // Floating point number initialised to zero.
- printf("This will run a loop while r is less than 1.8 but it doesn't work,"
- "\nso why does this happen and how do you fix it?"
- "\n\n");
- printf("Vaules of r and i before loop:\ni = %d r = %f"
- "\n\n",i,r);
- printf("And here's the values outputted during the loop:"
- "\n\n");
- while(r<1.8)
- {
- r+=0.3;
- i=r;
- printf(" i = %d r = %f\n", i, r);
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement