Thread: Cant get right output

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    16

    Question Cant get right output

    I'm working on a program called "Squirrelly in the Morning...".
    Overall, it's simple, but I cannot get one part of the output right.
    The input is a series of integers (i.e. 5, 10, 11, 3, 4, 5...).
    The program is looking to see if you are getting "warmer",
    "colder", or the "same" when comparing the first digit to the rest of the digits. The output should begin from 0 like this (using the digits above:
    Moving from 0 to 10: Same.
    Moving from 10 to 11: Colder
    Moving from 11 to 3: Warmer
    etc..
    My problem is, I can't get the out put to start from 0.
    Here is my code.
    int x,y,p,t;

    cin>>x;
    y=x;


    while (x != 5280)
    {

    x = 0;
    cin>>x;
    p = abs(y-x);

    if (p == 0)
    cout<<"Moving from "<<t<<" to "<<x<<": Found it!"<<endl;
    else if (y > p)
    cout<<"Moving from "<<t<<" to "<<x<<": Warmer"<<endl;
    else if (y < p)
    cout<<"Moving from "<<t<<" to "<<x<<": Colder"<<endl;
    else if(y == p)
    cout<<"Moving from "<<t<<" to "<<x<<": Same"<<endl;
    t = x;
    }
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    16
    Thanks Salem,
    I've been on this code for 2 days and never saw it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM