( Chapter 2 Program 7 )
Also visit our YouTube Channel Tech Eos VISIT CHANNEL
/* 7. Take marks from the user and print grade accordingly
( >=75 marks - Distinction , <75 and >=60 marks - First ,
<60 and >=50 - Second , <50 and >=35 - Pass , <35 - Fail)
using if ... else if... else statement and
also by using logical operators). */
#include<stdio.h>
#include<conio.h>
void main()
{
int marks ;
clrscr();
printf("\nEnter your marks : ");
scanf("%d" , &marks );
// Nested if
if( marks >= 75 )
{
printf("\n\nDistinction");
}
else if( marks >= 60 && marks <75 )
{
printf("\n\nFirst");
}
else if( marks >=50 && marks < 60 )
{
printf("\n\nSecond");
}
else if( marks >= 35 && marks <50 )
{
printf("\n\nPass");
}
else
{
printf("\n\nFail");
}
getch();
}
Comments
Post a Comment