If I have an algebraic expression that makes a sequance of numbers how do I count the number of integers in the sequence and output this?
The integers are coming from a do-while loop and I don't know how to count them.
Printable View
If I have an algebraic expression that makes a sequance of numbers how do I count the number of integers in the sequence and output this?
The integers are coming from a do-while loop and I don't know how to count them.
just create another variable that starts at zero and increment it with each iteration of the loop:Code:#include <iostream>
int main()
{
int iter=0;
do{
iter++;
std::cout<<iter<<std::endl;
}while(true);
return 0;
}