https://github.com/marko19907/cpp-exam
"C++ for programmers" (INFT2503) exam, fall 2022.
https://github.com/marko19907/cpp-exam
cmake cpp cpp-templates cpp14 exam lambda-functions object-oriented-programming operator-overloading smart-pointers
Last synced: 5 months ago
JSON representation
"C++ for programmers" (INFT2503) exam, fall 2022.
- Host: GitHub
- URL: https://github.com/marko19907/cpp-exam
- Owner: Marko19907
- Created: 2023-01-05T22:11:00.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-05T22:12:03.000Z (about 3 years ago)
- Last Synced: 2025-02-17T03:30:25.613Z (about 1 year ago)
- Topics: cmake, cpp, cpp-templates, cpp14, exam, lambda-functions, object-oriented-programming, operator-overloading, smart-pointers
- Language: C++
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C++ exam
The fall 2022 exam from the "C++ for programmers" (INFT2503) course.
Counts towards 100% of the final grade in the subject.
[](https://github.com/Marko19907/CPP-exam/actions/workflows/build.yml)
## Tasks
### Task 1
Create the necessary functions so that the following:
```C++
cout << concat("hello", "world") << endl;
cout << concat(1, 2) << endl;
cout << concat({"a", "b", "c"}) << endl;
```
Outputs this:
```
helloworld
12
abc
```
### Task 2
Create the necessary classes so that the following:
```C++
vector> animals;
animals.emplace_back(make_unique());
animals.emplace_back(make_unique());
animals.emplace_back(make_unique());
for(auto &a : animals)
cout << a->makeNoise() << endl;
```
Outputs this:
```
Toot!
Toot!
Honk!
```
### Task 3
Create the necessary functions so that the following:
```C++
cout << map_f({1, 2, 3}, [](int a){return a * 2;}) << endl;
cout << map_f({1, 2.3, 3}, [](float a){return a /2;}) << endl;
cout << map_f({"hello", "world"}, [](string s){return s + ".";}) << endl;
cout << map_f({"hello", "world"}, [](string s){return s.size();}) << endl;
```
Outputs this:
```
{ 2, 4, 6 }
{ 0.5, 1.15, 1.5 }
{ hello., world. }
{ 5, 5 }
```
### Task 4
Create the necessary classes so that the following:
```C++
Matrix m_a({{1, 2}, {3, 4}, {5, 6}});
Matrix m_b({{1, 2, 3}, {4, 5, 6}});
cout << m_a << endl;
cout << m_b << endl;
cout << m_a * m_b << endl;
cout << m_b * m_a << endl;
Matrix m_c({{1, 2}});
Matrix m_d({{2}, {2}});
cout << m_c * m_d << endl;
cout << m_d * m_c << endl;
```
Outputs this:
```
[ 1 2 ]
[ 3 4 ]
[ 5 6 ]
[ 1 2 3 ]
[ 4 5 6 ]
[ 9 12 15 ]
[ 19 26 33 ]
[ 29 40 51 ]
[ 22 28 ]
[ 49 64 ]
[ 6 ]
[ 2 4 ]
[ 2 4 ]
```