C program to accept percentage and print division accordingly.

Q22. Write a C program to accept percentage and print division accordingly.

Solution:

#include<stdio.h> //standard input/output header file

#include<conio.h> //for clrscr()

 

int main()

{

int per;

 

clrscr(); //for clearing the screen

 

printf(“\n Enter the percentage: “);

scanf(“%d”,&per);

 

per>=60?printf(“\n I Division.”) : per<60&&per>=45?printf(“\n II Division.”):per>=36?printf(“\n III Division.”) : printf(“\n Fail.”);

 

getch(); //holds the screen until any key is pressed

return 0; //makes main() finish

}

 

OUTPUT:

CASE 1:

 

Enter the percentage: 78

 

I Division.

 

CASE 2:

Enter the percentage: 57

 

II Division.

 

 

CASE 3:

Enter the percentage: 33

Fail

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: