Compare commits
No commits in common. "92d5fba1b8839b1c62608dde73e6fa55d014844c" and "d6e0a1a9df3b18c9c91c0559c2ab600985732c24" have entirely different histories.
92d5fba1b8
...
d6e0a1a9df
44
.gitignore
vendored
44
.gitignore
vendored
@ -21,47 +21,3 @@
|
||||
/python/.idea/vcs.xml
|
||||
/python/.idea/workspace.xml
|
||||
|
||||
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
|
||||
cpp/ANSI/W1/Day2/Ex.5/function-math
|
||||
cpp/ANSI/W1/Day3/3.1/sizeofvars
|
||||
cpp/ANSI/W1/Day3/3.2/variableusage
|
||||
cpp/ANSI/W1/Day3/3.4/overflow
|
||||
cpp/ANSI/W1/Day3/3.3/typedef
|
||||
cpp/ANSI/W1/Day3/3.5/overflowint
|
||||
cpp/ANSI/W1/Day3/3.6/printchars
|
||||
cpp/ANSI/W1/Day3/3.7/printchars2
|
||||
cpp/ANSI/W1/Day3/3.8/enumeratedconstants
|
||||
cpp/ANSI/W1/Day3/3.9/enumeratedconstants2
|
||||
cpp/ANSI/W1/Day3/Ex.SpecialChars/specialchars
|
||||
cpp/ANSI/W1/Day4/4.1/complexexpressions
|
||||
cpp/ANSI/W1/Day4/4.2/integerOverflow
|
||||
cpp/ANSI/W1/Day4/4.3/prefixPostfixOperators
|
||||
cpp/ANSI/W1/Day4/4.4/nestedif
|
||||
cpp/ANSI/W1/Day4/4.5/elseif
|
||||
cpp/ANSI/W1/Day4/4.6/complexnestedif
|
||||
cpp/ANSI/W1/Day4/4.7/brokenbracesif
|
||||
cpp/ANSI/W1/Day4/4.8/fixedbracesif
|
||||
cpp/ANSI/W1/Day4/Quiz/quiz
|
||||
cpp/ANSI/W1/Day4/Ex.LogicalOperators/logicaloperators
|
||||
cpp/ANSI/W1/Day4/4.9/conditionaloperator
|
||||
cpp/ANSI/W1/Day5/5.1/basicfunction
|
||||
cpp/ANSI/W1/Day5/5.10/fibonaccisequence
|
||||
cpp/ANSI/W1/Day5/5.2/localvariables
|
||||
cpp/ANSI/W1/Day5/5.3/localvariables2
|
||||
cpp/ANSI/W1/Day5/5.4/localvariables3
|
||||
cpp/ANSI/W1/Day5/5.5/localvariables4
|
||||
cpp/ANSI/W1/Day5/5.6/localvariables5
|
||||
cpp/ANSI/W1/Day5/5.7/defaultparamvalues
|
||||
cpp/ANSI/W1/Day5/5.8/polymorphism
|
||||
cpp/ANSI/W1/Day5/5.9/inlinefunctions
|
||||
|
||||
82
.vscode/settings.json
vendored
82
.vscode/settings.json
vendored
@ -1,82 +0,0 @@
|
||||
{
|
||||
"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",
|
||||
"iostream": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"atomic": "cpp",
|
||||
"strstream": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"charconv": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"source_location": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stdfloat": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
||||
28
.vscode/tasks.json
vendored
28
.vscode/tasks.json
vendored
@ -1,28 +0,0 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
5
cpp/.vscode/settings.json
vendored
5
cpp/.vscode/settings.json
vendored
@ -1,5 +0,0 @@
|
||||
{
|
||||
"vscord.app.whitelist": [
|
||||
"220362876546711552"
|
||||
]
|
||||
}
|
||||
28
cpp/.vscode/tasks.json
vendored
28
cpp/.vscode/tasks.json
vendored
@ -1,28 +0,0 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++-14 build active file",
|
||||
"command": "/usr/bin/g++-14",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,7 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
g++ $(CFLAGS) -o error main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: helloworld
|
||||
./helloworld
|
||||
|
||||
clean:
|
||||
rm -f helloworld
|
||||
@ -1,6 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
return 0;
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,11 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
1. What is the difference between an interpreter and a compiler?
|
||||
Interpreters are Just-in-time compilers that do not make binaries. They can be edited like editing a script. Where as a compiler makes binaries that can't be changed without changing the source code and recompiling.
|
||||
|
||||
2. How do you compile the source code with your compiler?
|
||||
I create a Makefile - that runs the command ```g++ -o PROJECT main.cpp``` creating a binary with the PROJECT name.
|
||||
|
||||
3. What does the linker do?
|
||||
The linker uses the local system libraries (Nix, Windows) to make system calls to the CPU.
|
||||
|
||||
4. What are the steps in the normal development cycle?
|
||||
a) brainstorm
|
||||
b) roadmap
|
||||
c) code
|
||||
d) debug
|
||||
e) publish
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,7 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,22 +0,0 @@
|
||||
// Listing 2.2 using std::cout
|
||||
#include <iostream>
|
||||
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;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,25 +0,0 @@
|
||||
// Listing 2.3 - using the keyword
|
||||
#include <iostream>
|
||||
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;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,24 +0,0 @@
|
||||
// Listing 2.4 - using the namespace std
|
||||
#include <iostream>
|
||||
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;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,17 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,20 +0,0 @@
|
||||
// Demonstrating a call to a function
|
||||
#include <iostream>
|
||||
|
||||
/* 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;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,24 +0,0 @@
|
||||
// Demonstrate some math using a function
|
||||
#include <iostream>
|
||||
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;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,30 +0,0 @@
|
||||
// Demonstrate some math using a function
|
||||
#include <iostream>
|
||||
int Add( int first, int second)
|
||||
{
|
||||
std::cout << "In Add() function, recived " << first << " and " << second << "\n";
|
||||
return(first + second);
|
||||
}
|
||||
|
||||
int Subtract( int first, int second)
|
||||
{
|
||||
std::cout << "In the Subtract() Function, received " << 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 Subtract() Function from main()\n";
|
||||
c=Subtract(a,b);
|
||||
cout << "\nBack in Main()\n";
|
||||
cout << "c was set to:\t" << c;
|
||||
cout << "\nExiting...\n\n";
|
||||
return 0;
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
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?
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o sizeofvars main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: sizeofvars
|
||||
./sizeofvars
|
||||
|
||||
clean:
|
||||
rm -f sizeofvars
|
||||
@ -1,19 +0,0 @@
|
||||
// Show the size of variable types on localhost
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using std::cout;
|
||||
|
||||
cout << "The size of an int is:\t\t" << sizeof(int) << " bytes.\n";
|
||||
cout << "The size of a short int is:\t" << sizeof(short) << " bytes.\n";
|
||||
cout << "The size of a long int is:\t" << sizeof(long) << " bytes.\n";
|
||||
cout << "The size of a char is:\t\t" << sizeof(char) << " bytes.\n";
|
||||
cout << "The size of a float is:\t\t" << sizeof(float) << " bytes.\n";
|
||||
cout << "The size of a _Float16 is:\t" << sizeof(_Float16) << " bytes.\n";
|
||||
cout << "The size of a __float128 is:\t" << sizeof(__float128) << " bytes.\n";
|
||||
cout << "The size of a double is:\t" << sizeof(double) << " bytes.\n";
|
||||
cout << "The size of a bool is:\t\t" << sizeof(bool) << " bytes.\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o variableusage main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: variableusage
|
||||
./variableusage
|
||||
|
||||
clean:
|
||||
rm -f variableusage
|
||||
@ -1,19 +0,0 @@
|
||||
// Demonstration on how to use variables
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
unsigned short int Width = 5, Length;
|
||||
Length = 10;
|
||||
|
||||
// create an unsigned short and initialize with results
|
||||
// of multiplying length by width
|
||||
unsigned short int Area = (Width * Length);
|
||||
|
||||
cout << "Width:\t" << Width << endl;
|
||||
cout << "Length:\t" << Length << endl;
|
||||
cout << "Area:\t" << Area << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o typedef main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: typedef
|
||||
./typedef
|
||||
|
||||
clean:
|
||||
rm -f typedef
|
||||
@ -1,21 +0,0 @@
|
||||
// Demonstration on what a typedef is how to declare one.
|
||||
#include <iostream>
|
||||
|
||||
typedef unsigned short int USHORT;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
USHORT Width = 5, Length;
|
||||
Length = 10;
|
||||
|
||||
// create an unsigned short and initialize with results
|
||||
// of multiplying length by width
|
||||
unsigned short int Area = (Width * Length);
|
||||
|
||||
cout << "Width:\t" << Width << endl;
|
||||
cout << "Length:\t" << Length << endl;
|
||||
cout << "Area:\t" << Area << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o overflow main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: overflow
|
||||
./overflow
|
||||
|
||||
clean:
|
||||
rm -f overflow
|
||||
@ -1,16 +0,0 @@
|
||||
// Demonstrating buffer overflow with unsigned short int
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
unsigned short int smallNumber = 65535;
|
||||
cout << "small number:\t" << smallNumber << endl;
|
||||
smallNumber++;
|
||||
cout << "small number:\t" << smallNumber << endl;
|
||||
smallNumber++;
|
||||
cout << "small number:\t" << smallNumber << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o overflowint main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: overflowint
|
||||
./overflowint
|
||||
|
||||
clean:
|
||||
rm -f overflowint
|
||||
@ -1,17 +0,0 @@
|
||||
// Demonstrating another overflow for a signed short int
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
short int smallNumber = 32767;
|
||||
|
||||
cout << "small number:\t" << smallNumber << endl;
|
||||
smallNumber++;
|
||||
cout << "small number:\t" << smallNumber << endl;
|
||||
smallNumber++;
|
||||
cout << "small number:\t" << smallNumber << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o printchars main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: printchars
|
||||
./printchars
|
||||
|
||||
clean:
|
||||
rm -f printchars
|
||||
@ -1,9 +0,0 @@
|
||||
// Demonstrate printing characters based on numbers
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i = 0; i<128; i++)
|
||||
std::cout << "i is equal to:\t" << i << "---: " << (char) i << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o printchars2 main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: printchars2
|
||||
./printchars2
|
||||
|
||||
clean:
|
||||
rm -f printchars2
|
||||
@ -1,9 +0,0 @@
|
||||
// Demonstrate printing characters with numbers take 2
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
for (unsigned char i = 0; i<128; i++)
|
||||
std::cout << "i is equal to:\t" << i << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o enumeratedconstants main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: enumeratedconstants
|
||||
./enumeratedconstants
|
||||
|
||||
clean:
|
||||
rm -f enumeratedconstants
|
||||
@ -1,19 +0,0 @@
|
||||
// Demonstrate enumerated constants
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };
|
||||
|
||||
Days today;
|
||||
today = Sunday;
|
||||
|
||||
if (today == Sunday || today == Saturday)
|
||||
cout << "\nGotta love the weekends!\n";
|
||||
else
|
||||
cout << "\nBack to work.\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o enumeratedconstants2 main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: enumeratedconstants2
|
||||
./enumeratedconstants2
|
||||
|
||||
clean:
|
||||
rm -f enumeratedconstants2
|
||||
@ -1,25 +0,0 @@
|
||||
// Same as before but with a const int list
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
const int Sunday = 0;
|
||||
const int Monday = 1;
|
||||
const int Tuesday = 2;
|
||||
const int Wednesday = 3;
|
||||
const int Thursday = 4;
|
||||
const int Friday = 5;
|
||||
const int Saturday = 6;
|
||||
|
||||
int today;
|
||||
today = Monday;
|
||||
|
||||
if (today == Sunday || today == Saturday)
|
||||
std::cout << "\nGotta’ love the weekends!\n";
|
||||
|
||||
else
|
||||
std::cout << "\nBack to work.\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
// List of special chars that can be used in chat with cout
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "the \\a character is an ALERT (bell)" << endl;
|
||||
cout << "The \\b character is a backspace..\b" << endl;
|
||||
cout << "the \\f operater is for form feed \fTest after the flag" << endl;
|
||||
cout << "the \\n operator is a newline character.\n";
|
||||
cout << "\rthe \\r operator is a Carraige return.\n\r";
|
||||
cout << "the \\t operator is a \tTab" << endl;
|
||||
cout << "the \\v operator is a vertial \vtab\n";
|
||||
cout << "the \\' operator is a single quote character \'Quotation\'\n";
|
||||
cout << "the \\\" operator is for double \"quotes\"\n";
|
||||
cout << "the \? operator is for Question Mark\n";
|
||||
cout << "the \\ operator is for Backslash\n";
|
||||
cout << "the \\000 operator is for Octal Notation \101\101\n";
|
||||
cout << "the \\xhhh is for Hexadecimal Notation \xFF\xAA\n";
|
||||
return 0;
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
1. What is the difference between an integer variable and a floating-point variable?
|
||||
|
||||
2. What are the differences between an unsigned short int and a long int?
|
||||
|
||||
3. What are the advantages of using a symbolic constant rather than a literal constant?
|
||||
|
||||
4. What are the advantages of using the const keyword rather than #define?
|
||||
|
||||
5. What makes for a good or bad variable name?
|
||||
|
||||
6. Given this enum, what is the value of BLUE?
|
||||
enum COLOR { WHITE, BLACK = 100, RED, BLUE, GREEN = 300 };
|
||||
|
||||
7. Which of the following variable names are good, which are bad, and which are
|
||||
invalid?
|
||||
a. Age
|
||||
b. !ex
|
||||
c. R79J
|
||||
d. TotalIncome
|
||||
e. __Invalid
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
1. What would be the correct variable type in which to store the following
|
||||
information?
|
||||
a. Your age
|
||||
b. The area of your backyard
|
||||
c. The number of stars in the galaxy
|
||||
d. The average rainfall for the month of January
|
||||
|
||||
2. Create good variable names for this information.
|
||||
|
||||
3. Declare a constant for pi as 3.14159.
|
||||
|
||||
4. Declare a float variable and initialize it using your pi constant.
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o complexexpressions main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: complexexpressions
|
||||
./complexexpressions
|
||||
|
||||
clean:
|
||||
rm -f complexexpressions
|
||||
@ -1,17 +0,0 @@
|
||||
// Demonstrating how to use Complex Expressions
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int a=0, b=0, x=0, y=35;
|
||||
cout << "a: " << a << " b: " << b;
|
||||
cout << " x: " << x << " y: " << y << endl;
|
||||
a = 9;
|
||||
b = 7;
|
||||
y = x = a+b;
|
||||
cout << "a: " << a << " b: " << b;
|
||||
cout << " x: " << x << " y: " << y << endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o integerOverflow main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: integerOverflow
|
||||
./integerOverflow
|
||||
|
||||
clean:
|
||||
rm -f integerOverflow
|
||||
@ -1,19 +0,0 @@
|
||||
// Demonstration of subtraction and Interger Overflow
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef unsigned int UINT;
|
||||
UINT difference;
|
||||
UINT bigNumber = 100;
|
||||
UINT smallNumber = 50;
|
||||
|
||||
difference = bigNumber - smallNumber;
|
||||
cout << "Difference is: " << difference;
|
||||
|
||||
difference = smallNumber - bigNumber;
|
||||
cout << "\nNow the difference is: " << difference << endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o prefixPostfixOperators main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: prefixPostfixOperators
|
||||
./prefixPostfixOperators
|
||||
|
||||
clean:
|
||||
rm -f prefixPostfixOperators
|
||||
@ -1,34 +0,0 @@
|
||||
/* Demonstrate use of prefix and postix increment
|
||||
and decrement operators */
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int myAge = 39; // Initialize two Integers
|
||||
int yourAge = 75;
|
||||
|
||||
cout << "I am: " << myAge << " years old.\n";
|
||||
cout << "You are: " << yourAge << " years old\n";
|
||||
myAge++; // Postfix increment
|
||||
++yourAge; // prefix increment
|
||||
|
||||
cout << "One year passes...\n";
|
||||
|
||||
cout << "I am: " << myAge << " years old.\n";
|
||||
cout << "You are: " << yourAge << " years old\n";
|
||||
myAge++; // Postfix increment
|
||||
++yourAge; // prefix increment
|
||||
|
||||
cout << "Another year passes...\n";
|
||||
|
||||
cout << "I am: " << myAge << " years old.\n";
|
||||
cout << "You are: " << yourAge << " years old\n";
|
||||
|
||||
cout << "Let's print it again.\n";
|
||||
cout << "I am: " << myAge << " years old.\n";
|
||||
cout << "You are: " << yourAge << " years old\n";
|
||||
return 0;
|
||||
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o nestedif main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: nestedif
|
||||
./nestedif
|
||||
|
||||
clean:
|
||||
rm -f nestedif
|
||||
@ -1,41 +0,0 @@
|
||||
/* Demonstrate use of if statement
|
||||
used with relational operators */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int metsScore, yankeesScore;
|
||||
cout << "Enter the score for the Mets: ";
|
||||
cin >> metsScore;
|
||||
|
||||
cout<< "\nEnter the score of the Yankees: ";
|
||||
cin >> yankeesScore;
|
||||
|
||||
cout << endl;
|
||||
|
||||
if (metsScore > yankeesScore)
|
||||
cout << "Let's Go Mets!\n";
|
||||
|
||||
if (metsScore < yankeesScore)
|
||||
{
|
||||
cout << "Go Yankees!\n";
|
||||
}
|
||||
if (metsScore == yankeesScore)
|
||||
{
|
||||
cout << "A tie? Naah, Can't be.\n";
|
||||
cout << "Give me the real score for the Yanks: ";
|
||||
cin >> yankeesScore;
|
||||
|
||||
if (metsScore > yankeesScore)
|
||||
cout << "Knew it! Let's go Mets!\n";
|
||||
if (metsScore > yankeesScore)
|
||||
cout << "Wow, go Yanks!\n";
|
||||
if (metsScore == yankeesScore)
|
||||
cout << "Wow, it really was a tie!\n";
|
||||
}
|
||||
cout << "\n Thanks for telling me.\n";
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o elseif main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: elseif
|
||||
./elseif
|
||||
|
||||
clean:
|
||||
rm -f elseif
|
||||
@ -1,21 +0,0 @@
|
||||
/* Demonstrates the use of the else clause
|
||||
while using the if condition */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int firstNumber, secondNumber;
|
||||
cout << "Please enter a big number: ";
|
||||
cin >> firstNumber;
|
||||
cout << "\nPlease enter a smaller number: ";
|
||||
cin >> secondNumber;
|
||||
if (firstNumber > secondNumber)
|
||||
cout << "\nThanks!\n";
|
||||
else
|
||||
cout << "\nWow, you should go back to first grade.\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o complexnestedif main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: complexnestedif
|
||||
./complexnestedif
|
||||
|
||||
clean:
|
||||
rm -f complexnestedif
|
||||
@ -1,32 +0,0 @@
|
||||
// Demonstrates advanced If statements
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
/*Ask for two numbers
|
||||
Assign the numbers to bigNumber and littleNumber
|
||||
if bigNumber is bigger than littleNumber,
|
||||
see if they are evenly divisle
|
||||
If they are, see if they are the same number */
|
||||
|
||||
using namespace std;
|
||||
|
||||
int firstNumber, secondNumber;
|
||||
|
||||
cout << "Enter two number.\nFirst: ";
|
||||
cin >> firstNumber;
|
||||
cout << "\nSecond: ";
|
||||
cin >> secondNumber;
|
||||
|
||||
if ( firstNumber >= secondNumber)
|
||||
{
|
||||
if ( (firstNumber % secondNumber) == 0) //evenly divisble - no remainder
|
||||
{
|
||||
if (firstNumber == secondNumber)
|
||||
cout << "They are the same!\n";
|
||||
}
|
||||
else
|
||||
cout << "They are not evenly divisble!\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o brokenbracesif main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: brokenbracesif
|
||||
./brokenbracesif
|
||||
|
||||
clean:
|
||||
rm -f brokenbracesif
|
||||
@ -1,22 +0,0 @@
|
||||
/* Demonstrates why braces are important inside
|
||||
nested if statements. This program will exit early.
|
||||
Not at the intended else clause, but in the nested if.*/
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int x;
|
||||
cout << "Enter a number less than 10 or greater than 100: ";
|
||||
cin >> x;
|
||||
cout << "\n";
|
||||
|
||||
if (x >= 10)
|
||||
if (x > 100)
|
||||
cout << "More than 100, Thanks!\n";
|
||||
else
|
||||
cout << "Less than 10, Thanks\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o fixedbracesif main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: fixedbracesif
|
||||
./fixedbracesif
|
||||
|
||||
clean:
|
||||
rm -f fixedbracesif
|
||||
@ -1,23 +0,0 @@
|
||||
/* Demonstrates the proper way to use braces
|
||||
to seperate if statements in advanced nested
|
||||
if statements*/
|
||||
#include <iostream>
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int x;
|
||||
cout << "Enter a number less than 10 or greater than 100: ";
|
||||
cin >> x;
|
||||
cout << endl;
|
||||
|
||||
if (x >= 100)
|
||||
{
|
||||
if (x > 100)
|
||||
cout << "More than 100, Thanks!\n";
|
||||
}
|
||||
else
|
||||
cout << "Less than 10, Thanks!\n";
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o conditionaloperator main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: conditionaloperator
|
||||
./conditionaloperator
|
||||
|
||||
clean:
|
||||
rm -f conditionaloperator
|
||||
@ -1,29 +0,0 @@
|
||||
// Demonstrates the conditional operator "?"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int x, y, z;
|
||||
cout << "Enter two numbers.\n";
|
||||
cout << "First number: ";
|
||||
cin >> x;
|
||||
cout << "\nSecond number: ";
|
||||
cin >> y;
|
||||
cout << endl;
|
||||
|
||||
if (x > y)
|
||||
z = x;
|
||||
else
|
||||
z = y;
|
||||
|
||||
cout << "After it test, z: " << z << endl;
|
||||
|
||||
/* This line is read as “If expression1 (x>y) is true, return the value of expression2; otherwise,
|
||||
return the value of expression3.” Assigned to variable "z" */
|
||||
z = (x > y) ? x : y;
|
||||
|
||||
cout << "After conditional test, z: " << z << endl;
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o logicaloperators main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: logicaloperators
|
||||
./logicaloperators
|
||||
|
||||
clean:
|
||||
rm -f logicaloperators
|
||||
@ -1,15 +0,0 @@
|
||||
/* A list of the logical operators in C++ */
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
cout << "The && operator means AND . ie if ( (x == 5) && (y == 5) )\n\n";
|
||||
cout << "The || operator means OR . ie if ( (x == 5) || (y == 5) )\n\n";
|
||||
cout << "The ! operator mean NOT equal to. ie if ( var1 != 420)\n\n";
|
||||
|
||||
// Appendix C has order of operations or relational precedence on conditional statements
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int x = 8+2*3;
|
||||
|
||||
cout << x << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
Quiz
|
||||
1. What is an expression?
|
||||
|
||||
2. Is x = 5 + 7 an expression? What is its value?
|
||||
|
||||
3. What is the value of 201 / 4?
|
||||
Depends on the datatype. If its an INT it would be 50. float would have the decimal. etc...
|
||||
4. What is the value of 201 % 4?
|
||||
0 because there would be a remainder so its not perfectly divisble
|
||||
5. If myAge, a, and b are all int variables, what are their values after
|
||||
myAge = 39;
|
||||
a = myAge++;
|
||||
b = ++myAge;
|
||||
|
||||
6. What is the value of 8+2*3?
|
||||
14 - follows pemdas?
|
||||
7. What is the difference between if(x = 3) and if(x == 3)?
|
||||
|
||||
Around page 80
|
||||
|
||||
|
||||
8. Do the following values evaluate true or false?
|
||||
a. 0
|
||||
b. 1
|
||||
c. –1
|
||||
d. x = 0
|
||||
e. x == 0 // assume that x has the value of 0
|
||||
|
||||
------------------------------------------------
|
||||
Exercises
|
||||
1. Write a single if statement that examines two integer variables and changes the
|
||||
larger to the smaller, using only one else clause.
|
||||
|
||||
2. Examine the following program. Imagine entering three numbers, and write what
|
||||
output you expect.
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
|
||||
int a, b, c;
|
||||
|
||||
cout << “Please enter three numbers\n”;
|
||||
cout << “a: “;
|
||||
cin >> a;
|
||||
cout << “\nb: “;
|
||||
cin >> b;
|
||||
cout << “\nc: “;
|
||||
cin >> c;
|
||||
|
||||
if (c = (a-b))
|
||||
cout << “a: “ << a << “ minus b: “ << b << ” equals c: “ << c;
|
||||
else
|
||||
cout << “a-b does not equal c: “;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o basicfunction main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: basicfunction
|
||||
./basicfunction
|
||||
|
||||
clean:
|
||||
rm -f basicfunction
|
||||
@ -1,26 +0,0 @@
|
||||
// Demonstrates how to declare functions
|
||||
#include <iostream>
|
||||
|
||||
int Area(int length, int width); // A function prototype because it ends with a semicolon
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
int lengthOfYard, widthOfYard, areaOfYard;
|
||||
|
||||
cout << "\nHow wide is your yard? ";
|
||||
cin >> widthOfYard;
|
||||
cout << "\nHow long is your yard? ";
|
||||
cin >> lengthOfYard;
|
||||
|
||||
areaOfYard = Area(lengthOfYard, widthOfYard);
|
||||
|
||||
cout << "\nYour yard is " << areaOfYard << " square feet!\n\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Area(int len, int wid)
|
||||
{
|
||||
return len * wid;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o fibonaccisequence main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: fibonaccisequence
|
||||
./fibonaccisequence
|
||||
|
||||
clean:
|
||||
rm -f fibonaccisequence
|
||||
Binary file not shown.
@ -1,36 +0,0 @@
|
||||
/* Demonstrates fibonacci series
|
||||
using recursion */
|
||||
#include <iostream>
|
||||
double fib(double n);
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
double n, answer;
|
||||
cout << "Enter number to find: ";
|
||||
cin >> n;
|
||||
cout << "\n\n";
|
||||
|
||||
answer = fib(n);
|
||||
|
||||
cout << answer << " is the " << n << "th Fibonacci number\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
double fib(double n)
|
||||
{
|
||||
cout << "Processing fib(" << n << ")...";
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
cout << "Return 1!\n";
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Call fib(" << n-2 << ") ";
|
||||
cout << "and fib (" << n-1 << ").\n";
|
||||
return (fib(n-2) + fib(n-1));
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o localvariables main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: localvariables
|
||||
./localvariables
|
||||
|
||||
clean:
|
||||
rm -f localvariables
|
||||
@ -1,24 +0,0 @@
|
||||
/* Demonstrates how variables defined inside functions
|
||||
are only available inside that function*/
|
||||
#include <iostream>
|
||||
|
||||
float Convert(float);
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
float TempFer;
|
||||
float TempCel;
|
||||
|
||||
cout << "Please enter the temperature in Fahrenheit: ";
|
||||
cin >> TempFer;
|
||||
TempCel = Convert(TempFer);
|
||||
cout << "\nHeres the temperate in Celsius: " << TempCel << endl;
|
||||
return 0;
|
||||
}
|
||||
float Convert(float TempFer)
|
||||
{
|
||||
float TempCel;
|
||||
TempCel = ((TempFer -32) * 5 ) / 9;
|
||||
return TempCel;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o localvariables2 main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: localvariables2
|
||||
./localvariables2
|
||||
|
||||
clean:
|
||||
rm -f localvariables2
|
||||
@ -1,35 +0,0 @@
|
||||
/* Demonstrates how the same variable name can be used in
|
||||
different functions with different values*/
|
||||
#include <iostream>
|
||||
using namespace std; // Global Declaration
|
||||
|
||||
void myFunc();
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std; // Local declaration
|
||||
|
||||
int x = 5;
|
||||
|
||||
cout << "In main the x value is: " << x << endl;
|
||||
|
||||
myFunc();
|
||||
cout << "\nBack in main again - and X is: " << x << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void myFunc()
|
||||
{
|
||||
int x = 8;
|
||||
cout << "In myFunc x is : " << x << endl;
|
||||
|
||||
{
|
||||
cout << "\nIn a nested code block inside myFunc X is: " << x << endl;
|
||||
|
||||
int x = 420;
|
||||
|
||||
cout << "Very local inside codeblock defined X is: " << x << endl;
|
||||
}
|
||||
|
||||
cout << "\nOut of the code block and back in myFun the x equals: " << x << " again.\n";
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o localvariables3 main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: localvariables3
|
||||
./localvariables3
|
||||
|
||||
clean:
|
||||
rm -f localvariables3
|
||||
@ -1,28 +0,0 @@
|
||||
/* Demonstrates passing by value. This means that when you pass
|
||||
a variable or value to a function; that function makes it's own
|
||||
copy of the variable. leaving the original value in tact in the calling function */
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
void swap(int x, int y);
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 5, y = 10;
|
||||
|
||||
cout << "Main. Before swap, X: " << x << " Y: " << y << endl;
|
||||
swap(x,y);
|
||||
cout << "Main. After swap, X: " << x << " Y: " << y << endl;
|
||||
}
|
||||
|
||||
void swap (int x, int y)
|
||||
{
|
||||
int temp;
|
||||
|
||||
cout << "in Swap. Before swap, X: " << x << " Y: " << y << endl;
|
||||
|
||||
temp = x;
|
||||
x = y;
|
||||
y = temp;
|
||||
|
||||
cout << "in Swap. After swap, X: " << x << " Y: " << y << endl;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o localvariables4 main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: localvariables4
|
||||
./localvariables4
|
||||
|
||||
clean:
|
||||
rm -f localvariables4
|
||||
@ -1,27 +0,0 @@
|
||||
/* Further demonstration of global and local variables */
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void myFunction();
|
||||
|
||||
int x = 5, y = 7; // Global variables
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "x from main: " << x << endl;
|
||||
cout << "y from main: " << y << endl;
|
||||
myFunction();
|
||||
cout << "Back from myFunction!" << endl << endl;
|
||||
cout << "x from main: " << x << endl;
|
||||
cout << "y from main: " << y << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void myFunction()
|
||||
{
|
||||
int y = 10;
|
||||
|
||||
cout << "x from myFunction: " << x << endl;
|
||||
cout << "y from myFunction: " << y << endl << endl;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o localvariables5 main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: localvariables5
|
||||
./localvariables5
|
||||
|
||||
clean:
|
||||
rm -f localvariables5
|
||||
@ -1,33 +0,0 @@
|
||||
/* Demonstrates multiple return statements */
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int Doubler(int AmountToDouble);
|
||||
|
||||
int main()
|
||||
{
|
||||
int result = 0, input;
|
||||
|
||||
cout << "Enter a number between 0 and 10,000 to double: ";
|
||||
cin >> input;
|
||||
|
||||
cout << "\nBefore doubler is called...";
|
||||
cout << "\nInput #: " << input << " doubled: " << result << "\n";
|
||||
|
||||
result = Doubler(input);
|
||||
|
||||
cout << "\nBack from doubler()...\n";
|
||||
cout << "\ninput #: " << input << " doubled: " << result << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Doubler(int original)
|
||||
{
|
||||
if (original <= 10000)
|
||||
return original * 2;
|
||||
else
|
||||
return -1;
|
||||
cout << "You cant get here!\n";
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o defaultparamvalues main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: defaultparamvalues
|
||||
./defaultparamvalues
|
||||
|
||||
clean:
|
||||
rm -f defaultparamvalues
|
||||
@ -1,31 +0,0 @@
|
||||
/* Demonstrates the use
|
||||
default parameter values */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int AreaCube(int length, int width = 25, int height = 1);
|
||||
|
||||
int main()
|
||||
{
|
||||
int length = 100;
|
||||
int width = 50;
|
||||
int height = 2;
|
||||
int area;
|
||||
|
||||
area = AreaCube(length, width, height);
|
||||
cout << "First area equals: " << area << endl;
|
||||
|
||||
area = AreaCube(length, width);
|
||||
cout << "Second time area equals: " << area << endl;
|
||||
|
||||
area = AreaCube(length);
|
||||
cout << "Third time area quals: " << area << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AreaCube(int length, int width, int height)
|
||||
{
|
||||
return (length * width * height);
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o polymorphism main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: polymorphism
|
||||
./polymorphism
|
||||
|
||||
clean:
|
||||
rm -f polymorphism
|
||||
@ -1,60 +0,0 @@
|
||||
/* Demonstrates function polymorphism
|
||||
also known as function overloading */
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int Double(int);
|
||||
long Double(long);
|
||||
float Double(float);
|
||||
double Double(double);
|
||||
|
||||
int main()
|
||||
{
|
||||
int myInt = 6500;
|
||||
long myLong = 65000;
|
||||
float myFloat = 6.5F;
|
||||
double myDouble = 6.5e20;
|
||||
|
||||
int doubledInt;
|
||||
long doubledLong;
|
||||
float doubledFloat;
|
||||
double doubledDouble;
|
||||
|
||||
cout << "myInt: " << myInt << endl << "myLong: " << myLong << endl;
|
||||
cout << "myFloat: " << myFloat << endl << "myDouble: " << myDouble << endl;
|
||||
|
||||
doubledInt = Double(myInt);
|
||||
doubledLong = Double(myLong);
|
||||
doubledFloat = Double(myFloat);
|
||||
doubledDouble = Double(myDouble);
|
||||
|
||||
cout << "doubledInt: " << doubledInt << "\ndoubledLong: " << doubledLong << endl;
|
||||
cout << "doubledFloat: " << doubledFloat << "\ndoubledDouble: " << doubledDouble << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Double(int original)
|
||||
{
|
||||
cout << "In Double*int)\n";
|
||||
return 2 * original;
|
||||
}
|
||||
|
||||
long Double(long original)
|
||||
{
|
||||
cout << "In Double(long)\n";
|
||||
return 2 * original;
|
||||
}
|
||||
|
||||
float Double(float original)
|
||||
{
|
||||
cout << "in Double(float)\n";
|
||||
return 2 * original;
|
||||
}
|
||||
|
||||
double Double(double original)
|
||||
{
|
||||
cout << "in Double(double)\n";
|
||||
return 2 * original;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o inlinefunctions main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: inlinefunctions
|
||||
./inlinefunctions
|
||||
|
||||
clean:
|
||||
rm -f inlinefunctions
|
||||
@ -1,30 +0,0 @@
|
||||
/* Demonstrates inline functions */
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
inline int Double(int);
|
||||
|
||||
int main()
|
||||
{
|
||||
int target;
|
||||
|
||||
cout << "Enter a number to work with: ";
|
||||
cin >> target;
|
||||
cout << endl;
|
||||
|
||||
target = Double(target);
|
||||
cout << "Target: " << target << endl;
|
||||
|
||||
target = Double(target);
|
||||
cout << "Target: " << target << endl;
|
||||
|
||||
target = Double(target);
|
||||
cout << "Target: " << target << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Double(int target)
|
||||
{
|
||||
return 2 * target;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o fibonaccisequence main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: fibonaccisequence
|
||||
./fibonaccisequence
|
||||
|
||||
clean:
|
||||
rm -f fibonaccisequence
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o fibonaccisequence main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: fibonaccisequence
|
||||
./fibonaccisequence
|
||||
|
||||
clean:
|
||||
rm -f fibonaccisequence
|
||||
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++03 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
1.1: main.cpp
|
||||
c++ $(CFLAGS) -o fibonaccisequence main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: fibonaccisequence
|
||||
./fibonaccisequence
|
||||
|
||||
clean:
|
||||
rm -f fibonaccisequence
|
||||
@ -1 +0,0 @@
|
||||
Day 5 - Page 120~; talking about registers
|
||||
Binary file not shown.
@ -1,13 +0,0 @@
|
||||
CFLAGS = -std=c++17 -O2
|
||||
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||
|
||||
HelloTriangle: main.cpp
|
||||
g++ $(CFLAGS) -o HelloTriangle main.cpp $(LDFLAGS)
|
||||
|
||||
.PHONY: test clean
|
||||
|
||||
test: HelloTriangle
|
||||
./HelloTriangle
|
||||
|
||||
clean:
|
||||
rm -f HelloTriangle
|
||||
@ -1,53 +0,0 @@
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib>
|
||||
|
||||
class HelloTriangleApplication {
|
||||
public:
|
||||
void run() {
|
||||
initVulkan();
|
||||
initWindow();
|
||||
mainLoop();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private:
|
||||
void initWindow() {
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
GLFWwindow* window;
|
||||
window = glfwCreateWindow(800, 600, "Vulkan", nullptr, nullptr);
|
||||
}
|
||||
|
||||
void initVulkan() {
|
||||
|
||||
}
|
||||
|
||||
void mainLoop() {
|
||||
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
HelloTriangleApplication app;
|
||||
|
||||
try {
|
||||
app.run();
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "Success!!!\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user