Unit Converter
In this project, you'll build a simple unit converter. A small but practical application to get you started with C++. We'll cover some common conversions like meters to feet, Celsius to Fahrenheit, and more. Everything will be explained step-by-step in great detail, so you won't miss a thing. This project is a great starting point for building your coding skills and learning how to tackle real-world problems.
Visual Studio Setup and Rundown
Steps
- Set up and test our application with a basic console output.
- Get input and store it in a variable. Output the variable to make sure it holds the right value.
- Multiply/Divide the user-input variable to convert it from one unit to another and output the result.
Code Snippets
00:49-00:58
Frech application
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
01:24-02:36
Step 1 code:
#include <iostream>
int main()
{
std::cout << "Unit Converter (cm => m)\nPlease input your number (in cm)";
}
02:39-03:15
Step 2 code:
#include <iostream>
int main()
{
std::cout << "Unit Converter (cm => m)\nPlease input your number (in cm)";
float userInput = 0;
std::cin >> userInput;
std::cout << userInput;
}
03:30-04:00
Step 3 code:
#include <iostream>
int main()
{
std::cout << "Unit Converter (cm => m)\nPlease input your number (in cm)";
float userInput = 0.f;
std::cin >> userInput;
std::cout << userInput << " cm is " << userInput / 100.f << "m.\n";
}