C++ program that prompts a user to specify a text through the keyboard repeatedly and only terminates when a user enters the text "goodbye" else the program should continue prompting a user to enter a text
#include<iostream>
using namespace std;
int main()
{
char str1[50]="Goodbye", str2[50];
int i=0, chk=0;
while(str1[i]!='\0' || str2[i]!='\0')
{
cout<<"Enter any text : ";
cin>>str2;
if(str1[i]!=str2[i])
{
chk = 1;
continue;
}
else
break;
i++;
}
return 0;
}
Comments
Leave a comment