For my computer lab class we were given a program with an infinite loop, and I am unsure what to do. Here is the program.
#include <iostream>
#include <string>
using namespace std;
int main() {
int Total; // running sum of the fraction total
int n; // number of fraction units
int Fraction; // will be 1/n;
int LoopCounter; // number of times for loop has executed so far
n = 2;
Fraction = 1/n;
LoopCounter = 0;
for (Total = 0; Total != 1; Total += Fraction) {
++LoopCounter;
}
cout << "The total is " << Total << "\n" ;
return 0;
Can someone help me with the terminating factor??