Skip to content

Commit 6a9eb5d

Browse files
committed
Added materail for Section04.
1 parent 2d5dd18 commit 6a9eb5d

File tree

55 files changed

+2089
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2089
-0
lines changed

Section04-Getting_Started/.DS_Store

8 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "clang++ - Build and debug active file",
9+
"type": "cppdbg",
10+
"request": "launch",
11+
"program": "${fileDirname}/${fileBasenameNoExtension}",
12+
"args": [],
13+
"stopAtEntry": false,
14+
"cwd": "${workspaceFolder}",
15+
"environment": [],
16+
"externalConsole": false,
17+
"MIMode": "lldb",
18+
"preLaunchTask": "C/C++: clang++ build active file"
19+
}
20+
]
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: clang++ build active file",
6+
"command": "/usr/bin/clang++",
7+
"args": [
8+
"-g",
9+
"${file}",
10+
"-o",
11+
"${fileDirname}/${fileBasenameNoExtension}"
12+
],
13+
"options": {
14+
"cwd": "${workspaceFolder}"
15+
},
16+
"problemMatcher": [
17+
"$gcc"
18+
],
19+
"group": {
20+
"kind": "build",
21+
"isDefault": true
22+
},
23+
"detail": "Task generated by Debugger."
24+
}
25+
],
26+
"version": "2.0.0"
27+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream> // input and output library
2+
3+
int main(){
4+
// Declare variable with type
5+
int num;
6+
7+
// Prompt string on terminal
8+
std::cout << "Enter your favorite number between 1 and 100: ";
9+
// What std::cout mean? https://www.cplusplus.com/forum/beginner/61121/
10+
// std::cout tells the compiler that I want the "cout" identifier, and that it is in the "std" namespace
11+
// [namespace][scope resolution operator][identifier]
12+
13+
// Take input from terminal
14+
std::cin >> num;
15+
// Similar to "cout", "cin" takes input
16+
17+
// Display on terminal after user input and end line + move cursor to next line
18+
std::cout << "Amazing! That's my favorite number too!" << std::endl;
19+
20+
return 0;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.apple.xcode.dsym.main</string>
9+
<key>CFBundleInfoDictionaryVersion</key>
10+
<string>6.0</string>
11+
<key>CFBundlePackageType</key>
12+
<string>dSYM</string>
13+
<key>CFBundleSignature</key>
14+
<string>????</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
</dict>
20+
</plist>
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Compiler error
2+
#include <iostream>
3+
int main(){
4+
std::cout << "Un-comment cases to view error" << std::endl;
5+
return 0;
6+
}
7+
8+
/*
9+
======== Syntax error ========
10+
#include <iostream>
11+
12+
int main(){
13+
std::cout << "Hello world << std::endl;
14+
return 0;
15+
}
16+
========================
17+
*/
18+
19+
20+
/*
21+
======== Syntax error ========
22+
#include <iostream>
23+
24+
int main(){
25+
std::cout << "Hello world" << std::endll;
26+
return 0;
27+
}
28+
========================
29+
*/
30+
31+
32+
/*
33+
======== Syntax error ========
34+
#include <iostream>
35+
36+
int main(){
37+
std::cout << "Hello world" << std::endl;
38+
return 0
39+
}
40+
========================
41+
*/
42+
43+
44+
/*
45+
======== Syntax error ========
46+
#include <iostream>
47+
48+
int main(){
49+
std::cout << "Hello world" << std::endl;
50+
return;
51+
}
52+
========================
53+
*/
54+
55+
56+
/*
57+
======== Semantic error ========
58+
#include <iostream>
59+
60+
int main(){
61+
std::cout << "Hello world" << std::endl;
62+
return "Joe";
63+
}
64+
========================
65+
*/
66+
67+
68+
/*
69+
================
70+
#include <iostream>
71+
72+
int main()
73+
std::cout << "Hello world" << std::endl;
74+
return 0;
75+
}
76+
========================
77+
*/
78+
79+
80+
/*
81+
================
82+
#include <iostream>
83+
84+
int main(){
85+
std::cout << ("Hello world" / 125) << std::endl;
86+
return 0;
87+
}
88+
========================
89+
*/
90+
91+
92+
/*
93+
======== Linker error ================
94+
#include <iostream>
95+
96+
extern int x;
97+
98+
int main(){
99+
100+
std::cout << "Hello world" << std::endl;
101+
102+
std::cout << x;
103+
104+
return 0;
105+
}
106+
========================
107+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.apple.xcode.dsym.main</string>
9+
<key>CFBundleInfoDictionaryVersion</key>
10+
<string>6.0</string>
11+
<key>CFBundlePackageType</key>
12+
<string>dSYM</string>
13+
<key>CFBundleSignature</key>
14+
<string>????</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
</dict>
20+
</plist>
Binary file not shown.
50.7 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
3+
int main(){
4+
5+
int num;
6+
7+
// num = 100;
8+
9+
std::cout << num << std::endl;
10+
11+
return 0;
12+
}
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.apple.xcode.dsym.main</string>
9+
<key>CFBundleInfoDictionaryVersion</key>
10+
<string>6.0</string>
11+
<key>CFBundlePackageType</key>
12+
<string>dSYM</string>
13+
<key>CFBundleSignature</key>
14+
<string>????</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
</dict>
20+
</plist>
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* Section 4 Challenge
2+
======================
3+
4+
Create a C++ program that asks the user for their favorite number between 1 and 100
5+
that read this number from console.
6+
7+
Suppose the user enters 24
8+
9+
Then display the following to the console:
10+
Amazing!! That's my favprite number too?
11+
No really!! 24 is my favorite number!
12+
13+
======================
14+
Enter your favorite number between 1 and 100: 24
15+
Amazing!! That's my favprite number too?
16+
No really!! 24 is my favorite number!
17+
18+
*/
19+
20+
#include <iostream>
21+
22+
int main(){
23+
int num;
24+
std::cout << "Enter your favorite number between 1 and 100: ";
25+
26+
std::cin >> num;
27+
28+
if (num > 0 && num < 101){
29+
std::cout << "Amazing!! That's my favprite number too?" << std::endl << "No really!! " << num << " is my favorite number!" << std::endl;
30+
}
31+
32+
return 0;
33+
}
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.apple.xcode.dsym.main</string>
9+
<key>CFBundleInfoDictionaryVersion</key>
10+
<string>6.0</string>
11+
<key>CFBundlePackageType</key>
12+
<string>dSYM</string>
13+
<key>CFBundleSignature</key>
14+
<string>????</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
</dict>
20+
</plist>
Binary file not shown.

0 commit comments

Comments
 (0)