-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule 1.cpp
42 lines (34 loc) · 1.03 KB
/
Module 1.cpp
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
#include <iostream>
int main() {
/*
//1.1
std::cout << "Hello world!\n";
//The errors were the fact that the functions were unknown due to the fact that
//iostream had not been included and a semicolon was missing at the end of the line.
*/
/*1.2 & 1.3
//read integers
std::cout << "Please enter two integer numbers\n";
int i;
std::cout << "i = ";
std::cin >> i;
int j;
std::cout << "j = ";
std::cin >> j;
//print calculations
std::cout << "i + j = " << i + j << "\n";
std::cout << "i - j = " << i - j << "\n";
std::cout << "i * j = " << i * j << "\n";
std::cout << "i / j = " << i / j << "\n";
std::cout << "i % j = " << i % j << "\n";
//Division only divides to whole numbers. When it is asked to divide by zero
//it just doesn't do it. Otherwise everything works as expected. The % operator
//gives the remainder after the initial division.
*/
//1.4
int n;
std::cout << "Please enter a natural number less than forty: ";
std::cin >> n;
std::cout << "Your prime number is: " << (n * n) + n + 41 << "\n";
return 0;
}