How to calculate GPA?
Grade point for S, A, B, C, D, E are 10, 9, 8, 7, 6, 5 correspondingly.
Example:
Grade | Credit
B | 3
E | 5
C | 3
B | 4
C | 4
Total credits = 19
sum of product of credit and
grade points for all the subjects = (8 * 3) + (5 * 5) + (7 * 3) + (8 * 4) + (7 * 4)
= 130
GPA = (sum of product of credit * grade points for all subjects) / total credits
= 130 / 19
GPA = 6.84
- Find the sum of credits of all the subjects.
- Find the sum of product of credit and grade point for all the subjects. Store the result in total.
- Divide total by sum of credits of all the subjects.
Grade point for S, A, B, C, D, E are 10, 9, 8, 7, 6, 5 correspondingly.
Example:
Grade | Credit
B | 3
E | 5
C | 3
B | 4
C | 4
Total credits = 19
sum of product of credit and
grade points for all the subjects = (8 * 3) + (5 * 5) + (7 * 3) + (8 * 4) + (7 * 4)
= 130
GPA = (sum of product of credit * grade points for all subjects) / total credits
= 130 / 19
GPA = 6.84
Write a C program to calculate GPA.
#include <stdlib.h>
#include <string.h>
int main() {
char str[100], ch;
int i, grade[5];
float credit[5], gpa = 0.0, totCredit = 0.0;
/* get the letter grade and credits from the user */
printf("Letter Grade and Credits for each subject:\n");
for (i = 0; i < 5; i++) {
printf("Subject %d(Grade|Credit):", i + 1);
ch = getchar();
grade[i] = ch;
scanf("%f", &credit[i]);
getchar();
}
/* print the input grades and credits */
printf("\nSubject | Grade | Credit\n");
for (i = 0; i < 5; i++) {
printf(" %d | %c | %.0f\n", i + 1, grade[i], credit[i]);
}
/* calculate gpa value */
for (i = 0; i < 5; i++) {
switch (grade[i]) {
case 'S':
gpa = gpa + 10 * credit[i];
totCredit = totCredit + credit[i];
break;
case 'A':
gpa = gpa + 9 * credit[i];
totCredit = totCredit + credit[i];
break;
case 'B':
gpa = gpa + 8 * credit[i];
totCredit = totCredit + credit[i];
break;
case 'C':
gpa = gpa + 7 * credit[i];
totCredit = totCredit + credit[i];
break;
case 'D':
gpa = gpa + 6 * credit[i];
totCredit = totCredit + credit[i];
break;
case 'E':
gpa = gpa + 5 * credit[i];
totCredit = totCredit + credit[i];
break;
default:
printf("Given Wrong grade!!\n");
exit(0);
}
}
printf("GPA: %f\tcredit: %f\n", gpa, totCredit);
gpa = gpa / totCredit;
printf("GPA for your score: %.2f\n", gpa);
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Letter Grade and Credits for each subject:
Subject 1(Grade|Credit):B 3
Subject 2(Grade|Credit):E 5
Subject 3(Grade|Credit):C 3
Subject 4(Grade|Credit):B 4
Subject 5(Grade|Credit):C 4
Subject | Grade | Credit
1 | B | 3
2 | E | 5
3 | C | 3
4 | B | 4
5 | C | 4
GPA: 130.000000 credit: 19.000000
GPA for your score: 6.84
Letter Grade and Credits for each subject:
Subject 1(Grade|Credit):B 3
Subject 2(Grade|Credit):E 5
Subject 3(Grade|Credit):C 3
Subject 4(Grade|Credit):B 4
Subject 5(Grade|Credit):C 4
Subject | Grade | Credit
1 | B | 3
2 | E | 5
3 | C | 3
4 | B | 4
5 | C | 4
GPA: 130.000000 credit: 19.000000
GPA for your score: 6.84
See Also:
- c program to print "Hello World"
- c program to print "Hello World" without using semicolon
- c program to swap two numbers
- c program to convert Celsius to Fahrenheit
- c program to convert Fahrenheit to Celsius
- c program to convert time in Hours:Minutes:Seconds to seconds
- c program to find the area of triangle given three sides
- c program to calculate Simple Interest
- c program to print multiplication table from 1 to n
- c program to check whether the given year is leap year or not
- c program to find the size of basic data types
- c program to find the area and circumference of a circle
- c program to find the roots of a quadratic equation
- c program to add two numbers
- c program to swap two numbers without using temporary variable
- c program to check whether the given number N is divisible by M
- c program to add two fractions
- c program to add two numbers without third variable
- c program to convert improper fraction to mixed fraction
- c program to convert centimeters to inches and feet
- c program to convert feet to inches
- c program to convert days into months and days
- c program to convert kilometers to miles, meters and feet
- c program to convert kilometer per hour to meter per second
- c program to convert kilograms to pounds and grams
- c program to convert minutes into hours
- c program to convert time in seconds to hours, minutes and seconds
- c program to convert hours, minutes to seconds
- c program to convert meter to feet and centimeters
- c program to convert plain to cipher text and cipher to plain text
- c program to convert pounds to kilograms
- c program to convert radians to degrees
- c program to convert year to roman equivalent
- c program to calculate compound interest
- c program to calculate power of a number
- c program to calculate factorial
- c program to find the area & perimeter of a circle, triangle, square and rectangle
- c program to calculate age in years, months and days
- c program to find absolute value of a given number
- c program to calculate age from date of birth
- c program to calculate body mass index
- c program to calculate distance between two points
- c program to calculate Greatest Common Divisor(GCD)
- c program to calculate Highest Common Factor(HCF)
- c program to calculate Least Common Multiple(LCM)
- c program to simplify the given fraction using GCF
- c program to calculate Gross and net salary of an employee
- c program to calculate Grades
- c program to calculate GPA
- c program to calculate income tax
- c program to calculate modulus
- c program to implement digital clock
- c program to calculate profit and loss
- c program to calculate percentage
- c program to calculate PI, resistance and power
- c program to calculate square root and square of a number
- c program to calculate volume of a cylinder and sphere
- c program to calculate weighted arithmetic mean
- c program to calculate x power y
- c program to check whether a date is valid or not
- c program to convert days into years, months and weeks
- c program to print date and sleep for a given time
- c program to clear screen and authenticate user
- c program to calculate generic root of any number
- c program to find largest digit of a number
- c program to generate multiplication table for the given number
- c program to convert decimal to binary and count the number of ones and zeros
- c program to round a number
- c program to guess a random number
- c program to implement ceaser cipher
- c program to swap nibble in a byte
- c program to find slope
- c program to calculate nCr and nPr
- c program to print even, odd and prime factors of a given number
- c program to print the four digit numbers whose sum of squares of first half and second half of the number equals the same number
- c program to check whether a given number is magic number or not
- c program to calculate correlation coefficient
plz someone help me!!!
ReplyDeletei want a program that i input a number of a subject in a program and that program show me the cgpa and gade point of that number. And this program will be create with function. plz some one help me to do this
ReplyDeleteJust see {Ali-noor}
ReplyDelete==================
#include
int main()
{
int marks;
printf("Enter Your Number\n");
scanf("%d",& marks);
if (marks>=80 && marks<=100)
{
printf("A+");
}
else if (marks<=79 && marks>=75)
{
printf("A");
}
else if (marks<=74 && marks>=70)
{
printf("A-");
}
else if (marks<=69 && marks>=65)
{
printf("B+");
}
else if (marks<=64 && marks>=60)
{
printf("B-");
}
else if (marks<=59 && marks>=55)
{
printf("C+");
}
else if (marks<=54 && marks>=50)
{
printf("C");
}
else if (marks<=49 && marks>=45)
{
printf("C-");
}
else if (marks<=44 && marks>=40)
{
printf("D");
}
else
printf("F");
return 0;
}
Can you please provide a flowchart for the program given in the blog.
ReplyDeleteI WANT A C PROGRAM OF 6 subjects average gpa using marks
ReplyDeletePlease give me the program mentioned up
ReplyDeleteSEO PowerSuite is a package which can help you with each factor of SEO to enable you to improve the search results overall performance of one's web site. This particular niche guest postPowerSuite review provides you with an in depth information with the benefits and features provided by SEO PowerSuite.
ReplyDeleteIf you want your web site to be on the first page of Google, Bing or Yahoo, you need to have the right kind of knowledge on the inner workings of search engines and learn pdf submission service. You have to be properly exposed to the latest technologies, programs and information available in terms of Search Engine Optimization.
ReplyDeleteOn-page and off-page factors are two different phases of your SEO efforts which work towards getting targeted audience, which provides the path that leads towards conversion. In the current scenario, achieving a strong online reputation requires implementing a versatile, solid and integrated pdf submission service techniques.
ReplyDeleteIn this article, I will discuss the top 4 reasons to use high citation flow backlinks. After reading this article, you should be fairly convinced about the power of backlinks.
ReplyDeleteOn-page and off-page factors are two different phases of your SEO efforts which work towards getting targeted audience, which provides the path that leads towards conversion. In the current scenario, achieving a strong online reputation requires implementing a niche backlinks, solid and integrated SEO techniques.
ReplyDeleteAny body helps me how iam add credit hours in programe
ReplyDeleteIf we talk about printers first name comes in our head is Brother Printers, for latest and updated Drivers for Brother go to the Following Sites.
ReplyDeletesolutions.brother.com/windows
solutions.brother.com/windows
solutions.brother.com/windows
solutions.brother.com/windows