Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Summation of Natural Number Sequence with c and c++.

#include<bits/stdc++.h>
using namespace std;
int main()
{    
  unsigned int a, b;    
  long long int sum = 0, n;    
  double s1;    
  cin >> a >> b;    
  n = (b-a) + 1;    
  sum = n * ((double)(a+b) / 2);    
  cout << sum << endl;        
  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to print double value up to 9 decimal places in c++ 
Cpp :: sfml thread multi argument function 
Cpp :: switch cout print with a prameter c++ 
Cpp :: c++ Difference Array | Range update query in O(1) 
Cpp :: std::is_standard_layout 
Cpp :: string in int in cpp 
Cpp :: Get the absolute path of a boost filePath as a string 
Cpp :: https://www.cplusplus.com/doc/tutorial/pointers/ 
Cpp :: viewlist exaple win32 
Cpp :: overload operator object function call 
Cpp :: accepting string with space on same line C++ 
Cpp :: nothrow new in cpp 
Cpp :: c++ put a function in a other thread 
Cpp :: c++ click event 
Cpp :: delete[] cpp 
Cpp :: how to add values in empty array using python 
Cpp :: Imports the elements in the array c++ 
Cpp :: C++ References 
Cpp :: haxelib install cpp 
Cpp :: determining a string is subsequence of another 
Cpp :: Accepting multiple inputs on the SAME LINE C++ 
Cpp :: Arduino C++ servomotor random moving 
Cpp :: operazioni aritmetiche c++ 
Cpp :: leetcode 36 c++ 
Cpp :: How to clear keyboard buffer c++ 
Cpp :: sort n characters in descending order c++ 
Cpp :: C++ Vector Initialization method 02 
Cpp :: ue4 log 
Cpp :: construct string with repeat limit 
Cpp :: Smooth Poti values on Arduino 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =