Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

While debugging this code I have noticed that at some specific point (info below) my variable with the name "counter" is changing from "1" to "0" for no specific reason. There: http://screencast.com/t/1pWDfHHqc Do you know why? I don't get it

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
#include using namespace std; int main() { int years,counter=0; double ValueCar; cout << "Value : "; cin >> ValueCar; cout << "Years : "; cin >> years; while (counter <= years) { counter++; if (counter == 1) ValueCar = ValueCar-ValueCar*30/100; if ((counter =! 1) && (counter <=8)) ValueCar = ValueCar - ValueCar*10/100; if (counter > 8) ValueCar = ValueCar - ValueCar*5/100; } if (ValueCar < 500) ValueCar = 500; cout << "The value of that car is " << ValueCar; return 0; }
I would guess it has something to do with your condition, if((counter =! 1), the operator should be != and I can't say for certain how it would react with the way you have it.
So whats the difference between != and =! ?

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

!= is a defined operator and =! isn't.
It might set your counter variable to 0 because it is interpreted as counter = false
thank you
You're welcome.

Not the answer you are looking for?

Search for more explanations.

Ask your own question