Thread: else if statement with example

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    99

    how to print different status ?

    I want to write c program to display status of student. if student get less then 40 marks then print " Failed". if he get mark's 40-50 then print "average. if he get marks 50- 70 then print "good" if he get mark's 70-100 then print "excellent "

    I was trying to write program but I am not getting status of student. How to print different status of students ?

    Code:
    #include<stdio.h>
        
    int main(void)
    {
     int marks;
     
     printf(" exam marks : ");
     
     scanf("%d", &marks);
     
     
     if (0 < marks && marks > 40)
     {
      printf ("failed");
     }
     
     else if (40 < marks && marks > 50)
     {
           printf ("average");
     }
        
     else if (50 < marks  && marks > 70)
     {
           printf ("Good");
     }
     return 0;
       
     }
    Last edited by vead; 11-30-2017 at 11:09 PM. Reason: right thread title

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 'If' Statement inside the Switch statement being ignored.
    By howardbc14 in forum C Programming
    Replies: 4
    Last Post: 04-11-2015, 11:45 AM
  2. Statement inside a statement.
    By JOZZY& Wakko in forum C Programming
    Replies: 15
    Last Post: 11-05-2009, 03:18 PM
  3. if statement
    By spencerhs5 in forum C Programming
    Replies: 3
    Last Post: 07-24-2006, 02:16 PM
  4. If Statement
    By boontune in forum C++ Programming
    Replies: 2
    Last Post: 09-17-2003, 07:56 AM
  5. if statement
    By ZakkWylde969 in forum C++ Programming
    Replies: 22
    Last Post: 07-11-2003, 10:48 PM

Tags for this Thread