Learning C++
Halfway through October, I wanted to start learning C++. C++ is an intimidating language, but I felt like I could tackle it.
So far, as of writing this, the most advanced thing I've made was a building that was built with the same number of floors as the number the user puts in. It is probably something every C++ programmer has done at least once as a beginner, and maybe it is put to good use for something more advanced. I dont know.
Sure, I have made more impressive things in other languages, but this is a first step in a new language that I didn't know much about two months ago.
The code is as follows:
#include
int askHowTall();
void buildBuilding(int input);
int main() {
buildBuilding(askHowTall());//asks how tall and returns input as value of buildings int.
}
int askHowTall() {
std::cout << "How tall do you want your building?:";
int input;
std::cin >> input;
return input;
}
void buildBuilding(int input) {
if (input != 0 && input < 1001) { // if input is not equal to 0
std::cout << " o \n";
std::cout << " ____|_____\n";
std::cout << " / | /| \n";
std::cout << " /________ //|\n";
for (int i = 0; i < input-1; i++) { // creates int i at value 0, and stays looping until i > input-1.
std::cout << "|= = = = =|//|\n";
}
std::cout << "|= = = = =|//\n";
std::cout << "|____O____|/\n";
} else {
std::cout << "NO FLOORS."; // if input not equal to 0 then say no floors.
}
}