skip to main | skip to sidebar

Sunday, August 21, 2011

How to find Grade equivalent using C Language

This program was the first requested tutorial on C programming Language using the Turbo C++ IDE.

This source code will determine the corresponding equivalent of your grade using the conditional structure if & else and selective structure switch.


Requested by: Jp Natividad


#include<stdio.h>
#include<conio.h>

float eq; // global variable

void main() // main function
{
clrscr();
int grade; // contains the value input

printf("enter your grade: ");
scanf("%d",&grade);


//conditions

if(grade <= 74 ) {
printf("FAILED");
eq = 5.00;
}
else if (grade >= 75 && grade <=100) {
printf("PASSED\n");

switch (grade){
case 75: case 76: case 77:
eq = 3.00; break;
case 78: case 79: case 80: case 81:
eq = 2.75; break;
case 82: case 83:
eq = 2.50; break;
case 84: case 85: case 86:
eq = 2.25; break;
case 87: case 88: case 89:
eq = 2.00; break;
case 90: case 91: case 92:
eq = 1.75; break;
case 93: case 94: case 95:
eq = 1.50; break;
case 96: case 97: case 98:
eq = 1.25; break;
case 99: case 100:
eq = 1.00; break;
default:
break;
}
}
else {
printf("invalid\n");

}
printf("your equivalent grade is: %.2f",eq);

getch();

}

0 comments:

Post a Comment