you have a musical friend ? , If no then sorry you cannot join . If yes , then what instrument you can play , if it is drum or guitar then welcome to the band if none than ,sorry
You cannot join the band .
use string and bool in programming
#include<iostream>
using namespace std;
bool musical_friend(string n){
if(n=="no"){
return false;
}
else {
return true;
}
}
void join_band(string n){
if(musical_friend(n)==false){
cout<<"Sorry you cannot join\n";
}
else{
cout<<"What instrument you can play\n";
string instrument;
cin>>instrument;
if(instrument=="drum" ||instrument=="guitar" ){
cout<<"Welcome to the band.\n";
}
else{
cout<<"Sorry. You cannot join the band \n.";
}
}
}
int main(){
cout<<"You have a musical friend ?\n ";
string n;
cin>>n;
join_band(n);
}
Comments
It was so helpful thanks a lot !
Leave a comment