mardi 5 avril 2016

C++ compare two numbers program not yielding results

I am learning the basics of C++. The following is a code I wrote to compare two numbers using "==" operator and print if they are equal or not. Can't understand why it won't work.

#include <iostream>

int main()
{
    using namespace std;
    int x, y;
    cin >> x;
    cin >> y;
    if
    {
        x == y;
        cout << "x and y are equal";
    }
    else
    {
        cout << "x and y are not equal";

    }
    system("pause");
    return 0;

}

Aucun commentaire:

Enregistrer un commentaire