Answer:
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.
main.cpp
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(){
//string for input
string input;
//index to store all input
int index=0;
//to store all names
string names[100];
//to store all ages
int ages[100];
//to store age
int age;
//to get name
string name;
while(true){
age = -999;
//read line input
getline(cin,input);
//convert to stream
stringstream ss(input);
//get name and age
ss>>name>>age;
//if name is -1 break the loop
if(name=="-1"){
break;
}
if(age!=0){
age++;
}
names[index] = name;
ages[index] = age;
index++;
}
cout<<"OUTPUT is as below"<<endl;
for(int i=0;i<index;i++){
cout<<names[i]<<" "<<ages[i]<<endl;
}
return 0;
}