-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum.cpp
More file actions
45 lines (40 loc) · 1.24 KB
/
sum.cpp
File metadata and controls
45 lines (40 loc) · 1.24 KB
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
//===========================================================
//sum.cpp
//Code to compute the sum of the integers which are the integer
//predecessors that lead up to a specific integer N on the positive
//real number line as defined in real space
//===========================================================
#include <iostream>
using namespace std;
int sum(int N);
//===========================================================
int main()
{
//get the integer N as input from the human implementing the program
cout<<"Input the integer N:> ";
int N;
cin>>N;
//Results of the sum
cout<< "==========================="//
<< endl;
cout<< "The sum of the integers which are the integer"
<< " predecessors that lead up to the specific integer " <<N<< " is "
<< sum(N) <<endl;
return 0;
}
//=================>>sum<<================================
//Returns the sum of the integers which are the integer
//predecessors that lead up to a specific integer N on the positive
//real number line as defined in real space
//============================================================
int sum(int N)
{
int sum = 0;
int counter = 1;
while(counter<N+1)
{
sum=sum+counter;
counter = counter+1;
}
return sum;
}