write a program in c++ which will takes input and asks tell me charactor. if answer is f then produce output i love you otherwise i hate you
Answers
Answered by
1
Answer:
#include <iostream>
int main()
{
string n;
cout<<"enter your name";
cin>>n;
char checkCharacter = 'f';
int count = 0;
for (int i = 0; i < n.size(); i++)
{
if (n[i] == checkCharacter)
{
++ count;
}
}
if(count<1)
{
cout<<"i love uh ";
}
else{
cout<<"i hate you ";
}
cout << "Number of " << checkCharacter << " = " << count;
return 0;
}
Explanation:
Similar questions