0
Cin and Cout in C++
hi, what is wrong with the following code? it just checks the first IF and print it regardless of the cin was 100 or not! #include <iostream> using namespace std; int main() { int dar; cin >> dar; if (dar = 100) { cout << "the number was 100" << endl; } else { cout << "Damn it again" << endl; } return 0; }
5 odpowiedzi
+ 5
You typed = where it should be ==.
Thus,use dar==100.
// == is equality, = is assignment.
+ 2
in which machine r u running this. it looks. very unsual.
+ 1
Thank you kinshuk, it works now. I just added ==
+ 1
if (dar == 100) {
0
On solo