C++ Help [ Beginner]

Posts 1–2 of 2 · Page 1 of 1
C++ Help [ Beginner]
Why it is not printing the second text?

Code:
#include <iostream>

using namespace std;

bool variable;

int main ()
{ 
    char c;
    cout << "Write a letter" << endl;
    cin >> c;
    
    switch (c)
    {
           case 'a':
           case 'e':
           case 'i':
           case 'o':
           case 'u':
           cout << "It's a vocal \n\n" << endl;
           break;                                    // Solamente se usa con switch
           default:                                  // se usa para si no pasa entonces.
                   variable = false;
   
    }
            if (variable = false)                       // This is just for practice, i know i could just added the text in DEfault
     {
               cout << "It's not a vocal \n" << endl;
     }   
    system("pause");
    return 0;
}
- - - Updated - - -

Never mind, i figured it out myself, somebody please close it.
In your if statement, you wrote "variable = false" instead of "variable == false".

= assigns a value, while == compares two values
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us