Ques:-7) The marks obtained by a student in 5 different subjects are input through the keyboard. The student gets a division as per the following rules:

Percentage above or equal to 75 – Honors

Percentage above or equal to 60 – First Division

Percentage between 50 and 59 – Second Division

Percentage between 40 and 49 – Third Division

Percentage less than 40 – Fail

Write a program to calculate the division obtained by the student

				
					#include<stdio.h>
#include<conio.h>
void main()
{
 int m1,m2,m3,m4,m5,per,total;
 clrscr();
 printf("Enter the marks obtained by a student in 5 different subjects\n");
 scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
 total=m1+m2+m3+m4+m5;
 printf("total marks obtained is:%d\n",total);
 per=total/5;
 printf("Percentage obtained is:%d\n",per);
 if(per<40)
 printf("fail\n");
 if(per>=40&&per<=49)
 printf("Third division\n");
 if(per>=50&&per<=59)
 printf("Second division\n");
 if(per>=60&&per<75)
 printf("First division\n");
 if(per>=75)
 printf("Honors");
 getch();
}

				
			

Out Put

Another program

				
					#include <stdio.h>

int main() {
    float marks[5];
    float total = 0;
    float percentage;
    int i;

    // Input marks for 5 subjects
    printf("Enter the marks obtained in 5 subjects: \n");
    for (i = 0; i < 5; i++) {
        printf("Subject %d: ", i + 1);
        scanf("%f", &marks[i]);
        total += marks[i];
    }

    // Calculate percentage
    percentage = (total / 500) * 100;

    // Determine division based on percentage
    printf("Total Marks = %.2f\n", total);
    printf("Percentage = %.2f%%\n", percentage);
    if (percentage >= 75) {
        printf("Division: Honors\n");
    } else if (percentage >= 60) {
        printf("Division: First Division\n");
    } else if (percentage >= 50) {
        printf("Division: Second Division\n");
    } else if (percentage >= 40) {
        printf("Division: Third Division\n");
    } else {
        printf("Division: Fail\n");
    }

    return 0;
}

				
			

Explanation:

  1. Variable Declaration:

    • marks[5] to store the marks of 5 subjects.
    • total to store the sum of all marks.
    • percentage to store the calculated percentage.
    • i for the loop index.
  2. Input Marks:

    • A loop is used to take input for the 5 subjects and simultaneously sum them up into the total.
  3. Calculate Percentage:

    • The percentage is calculated by dividing the total by 500 (since there are 5 subjects, and each subject is assumed to be out of 100) and then multiplying by 100.
  4. Determine Division:

    • Based on the percentage calculated, the program prints the division according to the given rules.

This program will take the marks of 5 subjects from the user, calculate the total and percentage, and then determine and print the division the student falls into.

Scroll to Top