write a c++ program that continue ask a user question and stop when user enter b
ID: 3590562 • Letter: W
Question
write a c++ program that continue ask a user question and stop when user enter bye. program will run like:Hi, welcome. How do you feel today? (user input) I feel sad why do you feel sad? (user input) Because i have bad grade why do you have bad grade? ... write a c++ program that continue ask a user question and stop when user enter bye. program will run like:
Hi, welcome. How do you feel today? (user input) I feel sad why do you feel sad? (user input) Because i have bad grade why do you have bad grade? ... program will run like:
Hi, welcome. How do you feel today? (user input) I feel sad why do you feel sad? (user input) Because i have bad grade why do you have bad grade? ...
Hi, welcome. How do you feel today? (user input) I feel sad why do you feel sad? (user input) Because i have bad grade why do you have bad grade? ...
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
int main(){
string question[5];
string answer;
question[0]="How are you?";
question[1]="What is your name?";
question[2]="How are you doing?";
question[3]="What is your favorite color?";
question[4]="What is your age?";
for(int i=0;i<5;i=(i+1)%5){
cout<<question[i]<<endl;
cin>>answer;
if(answer=="bye")exit(-1);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.