Answer to Question #280169 in C++ for A lawal

Question #280169

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


1
Expert's answer
2021-12-16T04:46:18-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog