Christos
  • Christos
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
katieb
  • katieb
See more answers at brainly.com
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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

Christos
  • Christos
#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; }
eSpeX
  • eSpeX
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.
Christos
  • Christos
So whats the difference between != and =! ?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

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

Looking for something else?

Not the answer you are looking for? Search for more explanations.