#include
#include
#define PI 3.14159265
using namespace std;
int main(){
int input = 1, sum = 0, entries = 0;
bool didBreak = false;
//simple for loop using the imcrement operator
for(int i = 0; i < 10; i++){
cout << "i: " << i << endl;
sum += i;
}
cout << "After the first FOR loop SUM currently stores: " << sum << endl;
//simple for loop using the decrement operator. what value will sum store at the end of this loop?
for(int i = 10; i > 0; i--){
cout << "i: " << i << endl;
sum -= i;
}
cout << "After the second FOR loop SUM currently stores: " << sum << endl << endl;
//resetting the value of sum
sum = 0;
//a while loop which accepts user input for an atbitary number of iterations
while(input != 0){
cout << "INPUT SUM: " << sum << endl;
cout << "***********************************" << endl;
cout << "Please enter a number: ";
cin >> input;
//increment entries as long as we haven't entered a 0 to quit loop
if(input != 0)
entries++;
//loop will continue if the user's entry is divisible by 7
if(input % 7 == 0){
cout << "CONTINUE hit, jumping back to loop head" << endl;
continue;
}
sum += input;
//loop will break if the sum is less than 0
if(sum < 0){
cout << "BREAK hit, exiting loop" << endl;
didBreak = true;
break;
}
//math things for filler (assumes input is in radians)
cout << "The sine of " << input << ": " << sin(input) << endl;
cout << "The cosine of " << input << ": " << cos(input) << endl;
}
cout << "***********************************" << endl;
if(didBreak == true){
cout << "Get the glue because you broke the loop" << endl;
sum *= -1; //flipping sign of negative sum for mod operation below
}
cout << "Total number of inputs: " << entries << endl;
cout << "***********************************" << endl;
cout << "Displaying the digits in SUM:" << endl;
//simple do-while loop implementation, prints the digits of the value stored in sum from least to most significant
do
{
cout << sum % 10 << endl;
sum /= 10;
}while(sum != 0);
return 0;
}