Thread: Help fixing code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    27

    Help fixing code

    Can anyone tell me whats wrong with my code? It has some syntax error in line 22,24 and 26 and when theres no syntax error it says its the weekend no matter what i type.

    Code:
    #include <stdio.h>
    int main () {
    
    char S, M, T, W, R, F, A, day;
    int hour;
    
    printf("Enter day of Week (S M T W R F A): ");
    scanf("%c", &day);
    
    if (day == S || A)
    printf("It's the weekend!\n");
    
    else if (day != S || M || T || W || R || F || A)
    printf("Invalid day entered.\n");
    
    else if (day == M || T || W || R || F || A || S)
    printf("Enter hour (0-23):\n");
    scanf("%d", &hour);
    
    if (hour >=0 && <8)
    printf("Still asleep\n");
    else if (hour >=8 && <18)
    printf("Should be at work\n");
    else if (hour >=18 && <24)
    printf("Off work\n");
    else printf("Hour Invalid\n");
    return 0;
    }
    Last edited by laserlight; 10-23-2012 at 10:29 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need some help fixing this code.
    By Mremokid1 in forum C Programming
    Replies: 4
    Last Post: 11-06-2011, 11:00 PM
  2. help in fixing this code..
    By transgalactic2 in forum C Programming
    Replies: 20
    Last Post: 12-13-2008, 06:38 AM
  3. help!!! code needs fixing
    By hockey123 in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2008, 06:02 PM
  4. Fixing old C-style code
    By tunafish in forum C Programming
    Replies: 6
    Last Post: 07-01-2005, 07:24 AM
  5. need help fixing up this code in allegro
    By Bobish in forum Game Programming
    Replies: 11
    Last Post: 04-06-2002, 02:50 PM