Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions ch01/ex1_09.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

#include <iostream>

using namespace std;

//“using namespace std” means we use the namespace named std. “std” is an abbreviation for standard.
//If we don’t want to use this line of code, we can use the things in this namespace like this. std::cout, std::endl.
//If this namespace is not used, then computer finds for the cout, cin and endl etc.. Computer cannot identify those and therefore it throws errors.


int main()
{
int sum = 0, val = 50;
while (val <= 100) {
sum += val;
++val;
sum += val; //shorthand for sum=sum+val
++val; //increments the value of val by 1.
}

std::cout << "the sum is: " << sum << std::endl;
cout << "The sum is: " << sum << endl;

return 0;
}

// output: the sum is: 3825
// output: The sum is: 3825