Thread: Elevator shaft help me out

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    1

    Smile Elevator shaft help me out

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      int u,d,n,t,r,m;
      float firsttry = t, firstrest = r, minutes = m;
     
      printf("Enter your parameters\n",n,u,d);
      scanf("%d %d %d", &n, &u, &d);
      getchar();
      
     if (n >100 )
     printf("You are dead dude");
      
      if  (n != 0)
        {     m += n;
        //calculation       
             t = n-u;
             r = t + d;
             
     {if  (r == 0)
     printf("It took %3.0d minutes", m);
        else
        r = n; 
     getchar();    
    }    
    } 
      return 0;
    }

    Program does run but does not give me any answers. Anyone out there who can help me out??? Thanks

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Pay attention to the warnings when you compile?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    It also makes things easier for everyone, including yourself, if you use more descriptive variable names.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057

Popular pages Recent additions subscribe to a feed