C++ unable to properly use I/O -
C++ unable to properly use I/O -
to begin with, i'm new c++. need decide whether given point inside or outside circle k.
for reason have written implementation of pythagoras'es theorem , simplified process much possible:
#include <iostream> using namespace std; int main(){ int x = 1; int y = 1; if (x*x+y*y<4){ cout << "point within circle" << endl; } else { cout << "point outside circle" << endl; } }
so want create variables user supplied input. however, next attempt:
cout << "value x: " << x; cin >> x; cout << "value y: " << y; cin >> y;
outputs next (as per first line): value x: 4273158 followed input.
these lines
cout << "value x: " << x; cin >> x; cout << "value y: " << y; cin >> y;
should this
cout << "please come in value x: "; cin >> x; cout << "value x: " << x; cout << "please come in value y: "; cin >> y; cout << "value y: " << y;
because got value x
before assigning value because compiler gives value you, though not guaranteed depending on compiler.
c++
Comments
Post a Comment