+ 10
How to deal with C++ questions, in which we have to tell the output of the given programme. Especially increment decrement ones.
7 ответов
+ 8
I'm unable to solve those questions in which we have to tell the output (C++). I want one to explain such questions of different patterns. (examples)
+ 8
Please guide
+ 8
I need to send you images of some questions.then you will get to know what solutions I am asking for.
how to send pics here?
+ 8
I'm not able to do above.
0
If I understand correctly, are you wanting to ask the user questions and depending on the answer, increment/decrement a score value?If so, are these questions yes/no based, age/number inputs? If so you can use if statements or bools for th checks. I could give an example if this is what you're looking for.
0
Well you didn't fully answer my question so I'll assume that's what you want to do.. Let's start with a true/false. This is without error checking...
int main()
{
char userInput;
int age;
cout << "Do you speak English?" << endl:
cin >> userInput
if( userInput == 'y')
{
//do something
cout << "How old are you?” << endl;
cin >> age;
if(age > 20)
{
//User is of age, do something?
}
else
{
// Do something else
}
}
else
{
// otherwise do something else
}
}
That is a very crude example of if/nested if statements for yes/no question and asking for an age.
Hope this helps.
0
You'll need to upload it somewhere and send me a link to the picture.