Can you help me w/ C++
#1

Hello,

This is the code:

http://s8.postimg.org/wlfr18ns5/scre...t_18_29_54.jpg

what the code does is: compare previous and current word in a while loop and then if the IF statement is true it executes whatever is in there

Please tell me how could previous be assigned current's value and used before the IF statement?

If you type Test Test the if statement would be true

Cheerio
Reply
#2

"Please tell me how could previous be assigned current's value and used before the IF statement?"

Just use current? That would be the next previous value, or do I simply not understand your question?
Reply
#3

I'll try to explain it in another way to you
Reply
#4

Maybe something like:
PHP код:
int main(int argcchar **argv) {
    
std::string current;
    
std::string previous;
    do  {
        
std::cin >> current;
        if (
current == previous) { // the previous word and the current one are the same
            
std::cout << "The word entered is the same as the old one." << std::endl;
            continue; 
// Continue the loop without executing the instructions below
        
}
        
// The previous word and the current one are different.
        
previous current;
        
std::cout << "The word entered is different from the old one." << std::endl;
    } while (
current != "exit");
    return 
0;

?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)