Please try to fix all three of the below problems. While these will run in the code window, it may be easier to debug these when running and compiling on the server. Your choice!
Compile and run the code below in your own C environment.
#include <stdio.h>
int main (void)
{
int i;
int total = 0;
for (i=0; i<=100; i--) {
total +=i;
}
printf("The sum of the numbers from 0 to 100 equals %d.\n", total);
return (0);
}
Compile and run the code below in your own C environment.
#include <stdio.h>
int main (void)
{
int total = 0;
int i = 0;
while (i<=100) {
total +=i;
}
printf("The sum of the numbers from 0 to 100 equals %d.\n", total);
return (0);
}
Compile and run the code below in your own C environment.
#include <stdio.h>
int main (void)
{
float sum;
int i = 0;
sum = 0.0;
while (sum != 1.0) {
sum = sum + 0.1;
i++;
}
printf("At the end of the loop the value of i equals %d.\n", i);
return (0);
}