What’s wrong with this code?

Asked

Viewed 81 times

-1

Why this code is not being compiled?

#include <iostream>
using namesapace std;
int main(){
long long xm;
long long ym;
long long xp;
long long yp;
cin>>xm;
cin>>ym;
cin>>xp;
cin>>yp;
long long t;
t=(xp+yp)-(xm+ym);
cout<<t<<endl;
}
  • 2

    Usually the compiler himself tells you this, just read the error message.

1 answer

1


It’s just a typo namespace is misspelled. This is because the code is written anyway. If you write a caution, whim makes it easier to avoid these mistakes and detect them more easily.

#include <iostream>
using namespace std;
int main() {
    long long xm;
    long long ym;
    long long xp;
    long long yp;
    cin >> xm;
    cin >> ym;
    cin >> xp;
    cin >> yp;
    long long t = (xp + yp) - (xm + ym);
    cout << t << endl;
}

Behold working in the ideone. Behold working in the repl it.. Also I put on Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.