When you in a new environment, meeting new people, or something like that. People must be wondering "who are you?". So the first thing that you gonna do is to introduce yourself.
But imagine, if you introduce yourself in such a way. Maybe you write it with a programming language? Sounds interesting? Well, just kidding.
Okay, let's jump to the main topic of how to write our bio using the C++ programming language.
First, we have to call the iostream library to the program :
#include <iostream>
If you want to not use std:: syntax before cout, we have to write this :
using namespace std;
Mostly, people will use the above syntax because it will make the coding syntax much simple and easier.
Next, we will write the main program :
main (){
string name, gender, job, nationality, birth_info,
address;
cout<<"\t\tINPUT YOUR DATA\n";
cout<<"---------------------------------------------\n";
cout<<"Input your name : ";
getline(cin, name);
cout<<"Input date and place of birth : ";
getline(cin, birth_info);
cout<<"Input your gender : ";
getline(cin, gender);
cout<<"Input your nationality : ";
getline(cin, nationality);
cout<<"Input your address : ";
getline(cin, address);
cout<<"Input your current job : ";
getline(cin, job);
cout<<"==============================================\n";
cout<<"\t\tID CARD\n";
cout<<"Name : "<<name<<endl;
cout<<"Date and place of birth : "<<birth_info<<endl;
cout<<"Gender : "<<gender<<endl;
cout<<"Nationality : "<<nationality<<endl;
cout<<"Job : "<<job<<endl;
cout<<"==============================================\n";
return 0;
}
Let's analyze the above code :
- The sign () is used to flanking the function arguments. In the main () function, no arguments are given so there are no entries in ().
- The { sign is used to indicate the start of program execution.
- The variable type string is used to declare variables in the form of sentences and numbers.
- To put a space in the type of string variable, we have to write getline (cin, variable_name)
- cout << "...."; used to print or display words.
- \ n and << endl; used for newline markers.
- \t used for horizontal tabulation (tab).
- Sign } as a sign of the end of program execution.
So, the overall program syntax will be :
#include <iostream>
using namespace std;
main (){
string name, gender, job, nationality, birth_info,
address;
cout<<"\t\tINPUT YOUR DATA\n";
cout<<"---------------------------------------------\n";
cout<<"Input your name : ";
getline(cin, name);
cout<<"Input date and place of birth : ";
getline(cin, birth_info);
cout<<"Input your gender : ";
getline(cin, gender);
cout<<"Input your nationality : ";
getline(cin, nationality);
cout<<"Input your address : ";
getline(cin, address);
cout<<"Input your current job : ";
getline(cin, job);
cout<<"==============================================\n";
cout<<"\t\tID CARD\n";
cout<<"Name : "<<name<<endl;
cout<<"Date and place of birth : "<<birth_info<<endl;
cout<<"Gender : "<<gender<<endl;
cout<<"Nationality : "<<nationality<<endl;
cout<<"Job : "<<job<<endl;
cout<<"==============================================\n";
return 0;
}
The output of the program will look like this :
Done!
So, that is the tutorial on how to make a bio with C ++. Hope it is useful. Thank you so much for reading!
Comentarios