C++
Learning the language C++.
Intro
Create a file with the extension .cpp
and write the following lines of code:
#include <iostream>
using namespace std;
int main() {
char name[32];
cout<<"Your name: ";
cin>>name;
cout<<"✨ Hi "<<name<<"!\n";
return 0;
}
Then run the application with Gcc and Make, but feel free to use other tools as you like.
Congratulations! 🎉 🎉 has written your first lines of code in C++. Maybe you still do not understand the instructions of the program well, but little by little it will discover a language to communicate with computers. lets' start! 🚀
Variables
A variable allows to store data, these are usually characters, integers or decimals. In C++ there are reserved words to define a variable type:
Variable type | Reserved keyword |
---|---|
Characters | char |
Integers | int |
Decimals | float , double |
Note :
float
anddouble
variables both store decimals; your choice will depend on the precision level of the decimals.
Definition of variable types:
#include <iostream>
using namespace std;
int main() {
char letter;
int friendsNumber;
float weight;
double earthLength;
}