Topic link
Title description
Programmatically input a character, output apple when the character is a, output banana when the character is b, output cat when the character is c, otherwise output no
Input to
enter a character
Output the
corresponding word
Sample Input
t
Sample Output
no
Ideas
Input a character, output apple when the character is a, output banana when the character is b, output cat when the character is c, otherwise output no.
C++ code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char c;
while(cin >> c)
{
if(c == 'a') cout << "apple" << endl;
else if(c == 'b') cout << "banana" << endl;
else if(c == 'c') cout << "cat" << endl;
else cout << "no" << endl;
}
return 0;
}