Skip to content

Commit 95b483a

Browse files
committed
chpt 1 ... 1.4
1 parent 28219e1 commit 95b483a

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Data_Structures_and_Algorithms_in_cpp
22

3-
hello :)
3+
hello :)
4+
5+
https://code.visualstudio.com/docs/cpp/config-linux#_debug-helloworldcpp
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <cstdlib>
2+
#include <iostream>
3+
#include <string>
4+
using std::string;
5+
using std::cout;
6+
7+
void characters() {
8+
std::cout << " 'A' = " << int('A') << std::endl;
9+
std::cout << "'\\0' = " << int('\0') << std::endl;
10+
}
11+
12+
void sizes() {
13+
std::cout << "size of int " << sizeof(int) << std::endl;
14+
std::cout << "size of long " << sizeof(long) << std::endl;
15+
std::cout << "size of char " << sizeof(char) << std::endl;
16+
17+
}
18+
19+
void usingStrings() {
20+
string s = "to be";
21+
string t = "not" + s;
22+
string u = s + " or " + t;
23+
if (s > t) {
24+
cout << u << std::endl;
25+
}
26+
27+
}
28+
29+
/* This program inputs two numbers x and y and outputs their sum */
30+
int main() {
31+
int x, y;
32+
std::cout << "Please enter two numbers: ";
33+
std::cin >> x >> y; // input x and y
34+
int sum = x + y; // compute their sum
35+
std::cout << "Their sum is " << sum << std::endl;
36+
37+
characters();
38+
sizes();
39+
usingStrings();
40+
41+
return EXIT_SUCCESS; // terminate successfully
42+
}

0 commit comments

Comments
 (0)