Thread: No Output

  1. #1
    Registered User
    Join Date
    Jun 2016
    Posts
    6

    No Output

    hi , my probleam cannot display output.. please comment so that i can fix the error
    Code:
    #include <stdio.h>
      int main()
    {
        int marks;
        printf("Enter Mark :");
        scanf("%d", &marks);
        switch (marks)
        {
        
        case 1:    if( marks > 80 && marks < 100)
                printf( " Grad A");
                break;
        case 2: if(marks > 70 && marks < 79  )
                printf( " Grad B");
                break;
        case 3: if( marks > 60 && marks < 69)
                printf( " Grad C");
                break;
        case 4: if( marks  >50 && marks < 59)
                printf( " Grad D");
                break;
        case 5: if( marks > 40 && marks < 49)
                printf( " Grad D");
                break;
        default: if( marks < 39)
                printf( " Grade F");
        
        }
        
    }
    Attached Files Attached Files

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    Try it without all the switch/case logic.

    You need only if statements.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2016
    Posts
    6
    tq...salem...it work.
    i delete all switch/case and replace with if and else if. Tq again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-14-2016, 08:27 AM
  2. C++ overlapping output and adding extensions to output files
    By lordmorgul in forum Linux Programming
    Replies: 9
    Last Post: 05-11-2010, 08:26 AM
  3. How to edit output in struct and call for the output
    By andrewkho in forum C Programming
    Replies: 4
    Last Post: 03-16-2010, 10:28 PM
  4. terminal output not showing output properly
    By stanlvw in forum C Programming
    Replies: 13
    Last Post: 11-19-2007, 10:46 PM
  5. Replies: 3
    Last Post: 02-19-2003, 08:34 PM

Tags for this Thread