Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Christos Group Title

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

  • one year ago
  • one year ago

  • This Question is Closed
  1. Christos Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #include <iostream> 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; }

    • one year ago
  2. eSpeX Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

    • one year ago
  3. Christos Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    So whats the difference between != and =! ?

    • one year ago
  4. eSpeX Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    != is a defined operator and =! isn't.

    • one year ago
  5. eSpeX Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    It might set your counter variable to 0 because it is interpreted as counter = false

    • one year ago
  6. Christos Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    thank you

    • one year ago
  7. eSpeX Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    You're welcome.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.