#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Please help me with weird output?


    Hi guys! I am completely new to programming and this forum. I just started trying to learn programming in C. In Xcode, however, when I enter this code


    #include <stdio.h>

    // print Fahrenheit-Celsius table for fahr=0,20,...,300//

    main()
    {
    int fahr, celsius;
    int lower, upper, step;

    lower=0;
    upper=300;
    step=20;

    fahr=lower;
    while (fahr <=upper){
    celsius=5*(fahr-32)/9;
    printf("%d\t%d\n",fahr,celsius);
    fahr=fahr+step;
    }
    }

    It gives me

    (lldb)

    as output. Can someone please tell me what's wrong? Also, for some reason "fahr int 1606422622" and "celsius int 32767" according to the variables view. Is this supposed to happen? Thank you so much in advance for your help!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0
    After I moved the code to main.c, it works perfectly.

    However, this code causes the same output of (lldb)

    #include <stdio.h>

    int main(void)
    {
    int i=10;
    do{
    printf("while:i is %d\n",i);
    i++;
    }while(i<10);
    printf("All done!\n");
    return 0;
    }

    Can someone please explain this?
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    Sounds like you're running the code from inside a debugger. The (lldb) is the debugger prompt. Maybe you're pushing the Debug button instead of the Run button to run your code.

    If you want to run it from inside the debugger, type r at the prompt and it will run through the code. Later on, learn how to set breakpoints and inspect variable values. When you get better at programming, learning how to use the debugger comes in very handy.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo