Elevator shaft help me out

This is a discussion on Elevator shaft help me out within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <stdlib.h> int main() { int u,d,n,t,r,m; float firsttry = t, firstrest = r, minutes = m; ...

  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,006
    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,048
    Reminds me of this . . . .

    Can't get the loop to work

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21