- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumBetweenNumbers.cpp
More file actions
Latest commit
29 lines (25 loc) · 585 Bytes
/
Copy pathSumBetweenNumbers.cpp
File metadata and controls
29 lines (25 loc) · 585 Bytes
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
//CSC114-651
//Student: Christopher Yonek (700642859)
//Assignment: Lab 4 - Create a program that sums the numbers between 0 and a specified number.
//Date: October 2018
#include"pch.h"
#include<iostream>
#include<conio.h>
usingnamespacestd;
intmain()
{
int num = 0;
int sum = 0;
cout << "Enter how many numbers you want to sum\n";
cin >> num;
while (num < 0){
cout << "Please enter positive integer only,\n";
cin >> num;
}
for (int i = 1; i <= num; i++){
sum += i;
}
cout << "The total sum is:" << sum;
_getch();
return0;
}