C++ Programming
- Write a C++ Program to print a welcome text in a separate line.
- Write a Program in C++ to add two numbers.
- C++ program for addition of two numbers using functions.
- Add two numbers in C++ using class.
- Addition of two numbers using call by reference in C++
- C++ program to write a program to add two numbers using call by value.
- Swapping of two numbers in C++ without using third variable.
- Swap two numbers in C++ using function.
- C++ program to swap two numbers using class.
- C++ program to swap two numbers using call by value.
- C++ program to swap two numbers using pointers.
- Write a program to swap private data members of two classes using friend function.
- write a program to add data objects of two different classes using friend function.
- Threading in C++.
- C++ thread lambda
- C++ thread lambda with parameter
- C++ thread lambda pass by reference
- Singleton C++ example
To calculate a mortgage payment, what types would you use for the rate, principal, and payment? Explain why you selected each type.
We can use float or double. Float takes 4 bytes of memory whereas double takes 8 bytes of memory. Float has a lower precision and it is used to store decimal numbers with fewer digits. Double has a higher precision and stores decimal numbers with more digits. Double has at most twice the precision. Float has 7 decimal digits of precision whereas double has 15 decimal digits of precision. So if precision is not the requirement, we can use float to save memory.
We can use the rate as a float like that: 5.69% per year. The principal like to float that, $1000.784. The payment like double that: $ 15000.147825.