My Need:
Using a while loop greet as many names as that are available on the stdin. Stop when you read the string '42' as a name.
My Coding:
#include<iostream>
using namespace std;
int main()
{
int input=1;
int i= 0;
string name;
while(input<=i)
{
cin>>name;
if(name=="42")
{
break;
}
else
{
cout<<"Hello "<<name<<"!";
i++;
}
}
return 0;
}
Result:
For input 42, test case is passed. For other input, test case failed. Please post your answer.
Answer After ~1 Year:
Very sorry for this question . This is I asked when I have 0 knowledge about C++. This may be useful for the freshers.