Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(int argc, char* argv[])
- {
- //question 1 - What are four ways to add 1 to an int.
- int x;
- x = 0;
- x++;
- ++x;
- x = x + 1;
- x += 1;
- cout << "X is " << x << endl;
- //question 2 - sum all the odd numbers between 0 and 100
- int sum;
- sum = 0;
- for (int i = 1; 1 <= 100; i++)
- {
- if (i % 2 != 0)
- sum = sum + i;
- }
- cout << "Sum of odd numbers is " << sum;
- return 0;
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement