Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sum of numbers in a series using sum formular
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 #include <iostream> double sum(int a, int b) { int big = b>a? b:a; int small = b>a? a:b; return ((a+b)/2.0)*(big - small +1); } int main() { int sum1{0}; for(int i = 3; i<=100; i++){ sum1 +=i; } std::cout << "Sum of numbers between 3 and 100 inclusive is: " << sum1 << std::endl; int x=3; int y = 100; std::cout<< "Sum between " << x << " and " << y << "[inclusive] = " << sum(x,y) << std::endl; std::cout << "Hello, world!\n"; }
run
|
edit
|
history
|
help
0
make_integer_sequence
MyCodeWindows
ccloader
ria
5sdgts
Dices by GOOSE
hangman
jkljklj
What exactly is “broken” with Microsoft Visual C++'s two-phase template instantiation?
Matrix_1