diff --git a/.gitignore b/.gitignore index a155db7..1c232f6 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,11 @@ cpp/vscode/helloworld cpp/vulkan/vulkantest/VulkanTest cpp/ANSI/W1/Day1/1.1/helloworld cpp/vulkan/HelloTriangle/HelloTriangle +cpp/ANSI/W1/Day2/2.1/helloworld +cpp/ANSI/W1/Day2/2.2/cout +cpp/ANSI/W1/Day1/Ex.1/math +cpp/ANSI/W1/Day2/2.3/keyword +cpp/ANSI/W1/Day2/2.4/namespace-std +cpp/ANSI/W1/Day2/2.5/comments +cpp/ANSI/W1/Day2/2.6/functions +cpp/ANSI/W1/Day2/2.7/function-math diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f50e6dd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "files.associations": { + "array": "cpp", + "hash_map": "cpp", + "chrono": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "string_view": "cpp", + "format": "cpp", + "initializer_list": "cpp", + "span": "cpp", + "ostream": "cpp" + } +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day1/Ex.1/Makefile b/cpp/ANSI/W1/Day1/Ex.1/Makefile new file mode 100644 index 0000000..ba265a9 --- /dev/null +++ b/cpp/ANSI/W1/Day1/Ex.1/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++11 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o math main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: math + ./math + +clean: + rm -f math diff --git a/cpp/ANSI/W1/Day1/Ex.1/main.cpp b/cpp/ANSI/W1/Day1/Ex.1/main.cpp new file mode 100644 index 0000000..3aa5ed5 --- /dev/null +++ b/cpp/ANSI/W1/Day1/Ex.1/main.cpp @@ -0,0 +1,11 @@ +#include + +int main() +{ + int x = 5; + int y = 7; + std::cout << std::endl; + std::cout << x + y << " " << x * y << std::endl; // Added the std::endl on this line because the line below no longer exists in the standard +// std::cout << std::end; //This no longer exists in the current C++ standard + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.1/Makefile b/cpp/ANSI/W1/Day2/2.1/Makefile new file mode 100644 index 0000000..398073c --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.1/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o helloworld main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: helloworld + ./helloworld + +clean: + rm -f helloworld diff --git a/cpp/ANSI/W1/Day2/2.1/main.cpp b/cpp/ANSI/W1/Day2/2.1/main.cpp new file mode 100644 index 0000000..e52a3fb --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.1/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::cout << "Hello World!\n"; + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.2/Makefile b/cpp/ANSI/W1/Day2/2.2/Makefile new file mode 100644 index 0000000..535867a --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.2/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o cout main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: cout + ./cout + +clean: + rm -f cout diff --git a/cpp/ANSI/W1/Day2/2.2/main.cpp b/cpp/ANSI/W1/Day2/2.2/main.cpp new file mode 100644 index 0000000..b81eec7 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.2/main.cpp @@ -0,0 +1,22 @@ +// Listing 2.2 using std::cout +#include +int main() +{ + std::cout << "Hello there.\n"; + std::cout << "Here is 5: " << 5 << "\n"; + std::cout << "The manipulator std::endl "; + std::cout << "writes a new line to the scren."; + std::cout << std::endl; + std::cout << "Here is a very big number:\t" << 70000; + std::cout << std::endl; + std::cout << "Here is the sum of 8 and 5:\t"; + std::cout << 8+5 << std::endl; + std::cout << "Here's a fraction:\t\t"; + std::cout << (float) 5/8 << std::endl; + std::cout << "And a very very vig number:\t"; + std::cout << (double) 7000 * 7000 << std::endl; + std::cout << "Don't forget to replace Jesse Liberty "; + std::cout << "with your name...\n"; + std::cout << "Ganome is a C++ programmer!\n"; + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.3/Makefile b/cpp/ANSI/W1/Day2/2.3/Makefile new file mode 100644 index 0000000..38959bb --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.3/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o keyword main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: keyword + ./keyword + +clean: + rm -f keyword diff --git a/cpp/ANSI/W1/Day2/2.3/main.cpp b/cpp/ANSI/W1/Day2/2.3/main.cpp new file mode 100644 index 0000000..f5683b2 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.3/main.cpp @@ -0,0 +1,25 @@ +// Listing 2.3 - using the keyword +#include +int main() +{ + using std::cout; + using std::endl; + + cout << "Hello there.\n"; + cout << "Here is 5:\t" << 5 << "\n"; + cout << "The manipulator endl "; + cout << "writes a new line to the screen."; + cout << endl; + cout << "Here is a very big number:\t" << 70000000; + cout << endl; + cout << "Here is the sum of 8 and 5:\t"; + cout << 8+5 << endl; + cout << "Here's a fraction:\t\t"; + cout << 5/8 << endl; + cout << "And a very big number:\t\t"; + cout << 7000 * 6000 << endl; + cout << "Dont forget to replace Jesse Liberty "; + cout << "with your name...\n"; + cout << "Ganome is a C++ programmer!\n"; + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.4/Makefile b/cpp/ANSI/W1/Day2/2.4/Makefile new file mode 100644 index 0000000..83ac4d8 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.4/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o namespace-std main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: namespace-std + ./namespace-std + +clean: + rm -f namespace-std diff --git a/cpp/ANSI/W1/Day2/2.4/main.cpp b/cpp/ANSI/W1/Day2/2.4/main.cpp new file mode 100644 index 0000000..5302d54 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.4/main.cpp @@ -0,0 +1,24 @@ +// Listing 2.4 - using the namespace std +#include +int main() +{ + using namespace std; + + cout << "Hello there.\n"; + cout << "Here is 5:\t" << 5 << "\n"; + cout << "The manipulator endl "; + cout << "writes a new line to the screen."; + cout << endl; + cout << "Here is a very big number:\t" << 70000000; + cout << endl; + cout << "Here is the sum of 8 and 5:\t"; + cout << 8+5 << endl; + cout << "Here's a fraction:\t\t"; + cout << 5/8 << endl; + cout << "And a very big number:\t\t"; + cout << 7000 * 6000 << endl; + cout << "Dont forget to replace Jesse Liberty "; + cout << "with your name...\n"; + cout << "Ganome is a C++ programmer!\n"; + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.5/Makefile b/cpp/ANSI/W1/Day2/2.5/Makefile new file mode 100644 index 0000000..4d85e29 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.5/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o comments main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: comments + ./comments + +clean: + rm -f comments diff --git a/cpp/ANSI/W1/Day2/2.5/main.cpp b/cpp/ANSI/W1/Day2/2.5/main.cpp new file mode 100644 index 0000000..34e3678 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.5/main.cpp @@ -0,0 +1,17 @@ +#include + +int main() +{ + using std::cout; + + /* This is a comment + and it extends until the closing + star-slash comment mark */ + cout << "Hello World!\n"; + //This comment ends at the end of this line! + cout << "That comment ended\n"; + + // double-slash comments cal also be alone on a line + /* as can slas-star comments */ + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.6/Makefile b/cpp/ANSI/W1/Day2/2.6/Makefile new file mode 100644 index 0000000..4fa66b9 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.6/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o functions main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: functions + ./functions + +clean: + rm -f functions diff --git a/cpp/ANSI/W1/Day2/2.6/main.cpp b/cpp/ANSI/W1/Day2/2.6/main.cpp new file mode 100644 index 0000000..94fa484 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.6/main.cpp @@ -0,0 +1,20 @@ +// Demonstrating a call to a function +#include + +/* function Demonstration Function +prints out a useful message */ +void DemonstrationFunction() +{ + std::cout << "In Demo Function\n"; +} + +/* function main - prints out a message, then +calls DemonstrationFunction(), then prints out +a second message*/ +int main() +{ + std::cout << "In main\n"; + DemonstrationFunction(); + std::cout << "Back in Main\n"; + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/2.7/Makefile b/cpp/ANSI/W1/Day2/2.7/Makefile new file mode 100644 index 0000000..610e835 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.7/Makefile @@ -0,0 +1,13 @@ +CFLAGS = -std=c++03 -O2 +LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + +1.1: main.cpp + c++ $(CFLAGS) -o function-math main.cpp $(LDFLAGS) + +.PHONY: test clean + +test: function-math + ./function-math + +clean: + rm -f function-math diff --git a/cpp/ANSI/W1/Day2/2.7/main.cpp b/cpp/ANSI/W1/Day2/2.7/main.cpp new file mode 100644 index 0000000..864e338 --- /dev/null +++ b/cpp/ANSI/W1/Day2/2.7/main.cpp @@ -0,0 +1,24 @@ +// Demonstrate some math using a function +#include +int Add( int first, int second) +{ + std::cout << "In Add() function, recived " << first << " and " << second << "\n"; + return(first + second); +} + +int main() +{ + using namespace std; + + cout << "I'm in the main() function!\n"; + int a, b, c; // Declare some variables adding + cout << "Enter two numbers: "; + cin >> a; + cin >> b; + cout << "\nCalling Add() Function from main()\n"; + c=Add(a,b); + cout << "\nBack in Main()\n"; + cout << "c was set to:\t" << c; + cout << "\nExiting...\n\n"; + return 0; +} \ No newline at end of file diff --git a/cpp/ANSI/W1/Day2/Quiz/quiz.txt b/cpp/ANSI/W1/Day2/Quiz/quiz.txt new file mode 100644 index 0000000..2ca86fe --- /dev/null +++ b/cpp/ANSI/W1/Day2/Quiz/quiz.txt @@ -0,0 +1,9 @@ +1. What is the difference between the compiler and the preprocessor? + +2. Why is the function main() special? + +3. What are the two types of comments, and how do they differ? + +4. Can comments be nested? + +5. Can comments be longer than one line? \ No newline at end of file