hey sir,
i need your help to solve a program?
question is= write a program for assesment system of university. the basic idea is to calculate the GPA of each subject and then calculate the GPA of whole semester and the basic of that GPA calculate the grade and remarks?
three subjects(english,computer,calculus) as input from the user. calculate the GPA of each subject and the whole semester. total marks of a subject are 100 and each subject is of 3 credit hours.

Dani AI

Generated

asked for a simple GPA calculator for three subjects. As and pointed out, showing the code and compiler/output errors is essential; reminded that an attempt is expected. Common reasons a C program "does not work" here are: missing ampersands in scanf, wrong format specifiers (%d vs %f), integer division when a floating result is required, uninitialized variables, or input values outside the expected range. Compile with warnings to catch many issues (for example gcc -std=c99 -Wall -Wextra -o gpa gpa.c).

A compact example follows. It uses a simple percentage-to-grade-point mapping (adjust thresholds to match the university policy), validates input, prints per-subject letter and grade point, and computes the semester GPA using credit hours.

#include <stdio.h>

float grade_point(int m){
    if (m >= 90) return 4.0f;
    if (m >= 80) return 3.0f;
    if (m >= 70) return 2.0f;
    if (m >= 60) return 1.0f;
    return 0.0f;
}

const char* grade_letter(int m){
    if (m >= 90) return "A";
    if (m >= 80) return "B";
    if (m >= 70) return "C";
    if (m >= 60) return "D";
    return "F";
}

int main(void){
    int marks[3], credit = 3, total_credits = credit * 3;
    const char *names[3] = {"English","Computer","Calculus"};
    for (int i = 0; i < 3; ++i){
        printf("Marks for %s (0-100): ", names[i]);
        if (scanf("%d", &marks[i]) != 1 || marks[i] < 0 || marks[i] > 100){
            printf("Invalid input\n"); return 1;
        }
    }
    float total_points = 0.0f;
    for (int i = 0; i < 3; ++i){
        float gp = grade_point(marks[i]);
        printf("%s: %d -> %s (%.1f)\n", names[i], marks[i], grade_letter(marks[i]), gp);
        total_points += gp * credit;
    }
    printf("Semester GPA: %.2f\n", total_points / total_credits);
    return 0;
}

Notes: the semester GPA is calculated as sum(grade_point * credit) / total_credits; with equal credits this is the average of grade points. If compilation or runtime output still looks wrong, consult the compiler warnings and the exact error messages (they usually indicate the culprit such as bad scanf, wrong specifier, or missing includes). Adjust grade thresholds and remarks to match the actual assessment rules.

Recommended Answers

All 4 Replies

What, specificially, do you need help with? Post what you have done so far, even if its wrong, and ask specific question(s).

Daniweb member rules sais this: Do provide evidence of having done some work yourself if posting questions from school or work assignments. I don't see any attempt of doing this program. Also, we won't just hand you the program. So start working on it, and only when you encounter problems, you come here and ask for help. Good luck.

sir i do it but it is not working on my pc

Post which is not working in your PC.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.