https://github.com/haimonmon/cpp-practice-hub
learning C++ with short simple exercises
https://github.com/haimonmon/cpp-practice-hub
cpp learn-to-code learning-exercise practice-programming programming-language
Last synced: 11 months ago
JSON representation
learning C++ with short simple exercises
- Host: GitHub
- URL: https://github.com/haimonmon/cpp-practice-hub
- Owner: Haimonmon
- Created: 2025-01-14T11:27:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-27T12:55:52.000Z (about 1 year ago)
- Last Synced: 2025-01-27T13:50:13.149Z (about 1 year ago)
- Topics: cpp, learn-to-code, learning-exercise, practice-programming, programming-language
- Language: C++
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
C++ Practice Hub

This repository presents a collection of small exercises to help me become familiar with C++ programming.
## Contents
* [ Water Consumption Calculator ](#water-consumption-calculator)
* [ Basic Arithmetic Calculator ](#basic-arithmetic-calculator)
* [ Palindrome ](#palindrome)
* [ Piggy Bank ](#piggy-bank)
* [ First Three Multiple ](#first-three-multiple)
* [ Tenth Power ](#tenth-power)
* [ Dog Years ](#dog-years)
* [ Quadratic Formula ](#quadratic-formula)
## Water Consumption Calculator
## Basic Arithmetic Calculator
## Palindrome
Define a function is_palindrome() that takes:
An std::string parameter text.
The function should return:
true if text is a palindrome.
false if text is not a palindrome.
(A palindrome is any text that has the same characters backwards as it does forwards. For example, “hannah” and “racecar” are palindromes, while “menu” and “aardvark” are not.)
We will not test for edge cases such as capitalization or spaces.
### Example Output
```cpp
int main()
{
std::cout << is_palindrome("madam") << "\n"; // 1
std::cout << is_palindrome("ada") << "\n"; // 1
std::cout << is_palindrome("lovelace") << "\n"; // 0
}
```
##
## Piggy Bank
## First Three Multiple
Write a function named first_three_multiples() that has:
An int parameter named num.
The function should return an std::vector of the first three multiples of num in ascending order.
### Example Output
```cpp
int main()
{
for (int num: first_three_multiples(7))
{
std::cout << num << std::endl; // 7, 14, 21
}
}
```
##
## Tenth Power
Write a function named tenth_power() that has:
An int parameter named num.
The function should return num raised to the 10th power.
### Example Output
```cpp
int main()
{
std::cout << tenth_power(0) << "\n"; // 0
std::cout << tenth_power(1) << "\n"; // 1
std::cout << tenth_power(2) << "\n"; // 32
}
```
## Dog Years
## Quadratic Formula