I have lately decided to take up learning c++ and it's been quite fun at first I encountered the problem of the console closing immediately after an output which could be solved by adding System("pause") now i have a program that has two inputs and after the first input the console closes without showing me any output and I couldn't fix it with system("pause").
#include <iostream>
using namespace std;
int main(){
char name[50];
int age;
cout << "Please enter your name? ";
cin >> name;
cout << endl << "Okay, how old are you ? ";
cin >> age;
cout << "Nice to meet you, " << name << "!" endl;
if (age < 10) cout << "Oh, you're quite young aren't you!" << endl; else
if (age < 20) cout << "Embrace your teens they won't last long!" << endl else
if (age < 40) cout << "Ah, I see you're still in your prime" << endl else
if (age < 60) cout << "That's nice" << endl;
return 0;
}