Created
July 2, 2015 14:31
-
-
Save jlegendary/d2ce70a1fabcfe202889 to your computer and use it in GitHub Desktop.
Revisions
-
jlegendary created this gist
Jul 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ for ( count = 0; count < internetHits; count++) // First start with 0 count and repeat until it is less than internetHits { // Starts the loop, this is the block of the loop cout << "Enter the number of Internet hits for Hour" << // Outputs string: Enter the number of internet hits in an hour (count + 1) << ": " // Outputs count+1: I don't know why you did this. This just outputs whatever // count is plus 1. So first output would be 1, 2 until it gets to internetHit cin >> internetHits; // Input internetHits. You would have to put this outside the loop, otherwise // it will keep asking you to input internetHits } #include <iostream> // Needed if you're using cout or cin using namespace std; // eliminates the need to add std:: in front of cout and cin and endl // although C++ community perfer you not to use using namespace std; int main() // Starts the main function { int internetHits = 0; // At this point, the internetHit is 0, until you set it. int count; // This makes it so it makes a variable in your RAM, currently it's // empty, until you initialize it. cout << "Enter the number of Internet hits for an hour" << endl; //THis is outside the loop, so it will output once cin >> internetHits; //Outside the loop, so it will ask you to input once. // Once you input, the value of internetHits will change for (count=0; count<internetHits; count++) //Starts the loop, since you have set the value to internetHit { cout << " : " << count << endl; // This will keep pumping out count until it hits the internetHits } return 0; } Example: So when it asks you for input, and you put 5. Program will output: 0 1 2 3 4 5