blob: 2cccd65b8602768ed58cc583106eca4775f4158b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <iostream>
/*
*
* For looping
*
*
*
*
*
*/
int main (void) {
for(int val = 1 ; val <= 10 ; val++) {
std::cout << val << std::endl;
}
for(int val2 = 10 ; val2 >= 1 ; val2--) {
std::cout << val2 << std::endl;
}
std::cout << "Done." << std::endl; // We send text to 'cout' a so called 'ostream'
int64_t one = 0;
int64_t two = 0;
int64_t sum = 0;
std::cin >> one >> two;
int64_t original_one = one;
for( ; one <= two ; one++) {
sum += one;
}
std::cout << "The sum of "<< original_one << " to " << two << " inclusive is: " << sum << std::endl;
int64_t sum2 = 0;
for(int64_t i = -100 ; i <= 100 ; ++i) {
sum2 += i;
}
std::cout << sum2 << std::endl;
std::cout << "Insert as many numbers as you want" << std::endl;
std::cout << "Press CTRL + D when done." << std::endl;
int value = 0, sum3 = 0;
while(std::cin >> value) {
sum3 += value;
}
std::cout << "sum of your numbers: " << sum3 << std::endl;
return 0;
}
|