Program to read the roll no, name and marks of three subjects and calculate the total, percentage and division.

Here, we have a basic program example to calculate the total marks percentage and division using different languages. This program is created in c language, c++, Java, and Python.

Program to calculate total marks and percentage of a student in C language

#include <stdio.h>
#include <string.h>

void main()
{
    int rollNo,marks1,marks2,marks3,total;
    float percentage;
    char name[20];
    printf("Enter the Roll Number of the student : ");
    scanf("%d",&rollNo);
    printf("Enter the Name of the Student : ");
    scanf("%s",name);
    printf("Enter the marks of first subject : ");
    scanf("%d",&marks1);
    printf("Enter the marks of second subject : ");
    scanf("%d",&marks2);
    printf("Enter the marks of third subject : ");
    scanf("%d",&marks3);
    total = marks1+marks2+marks3;
    percentage = total/3.0;
    printf("Total marks = %d\n",total);
    printf("Percentage = %5.2f\n",percentage);

    if (percentage>=60)
	 printf("Division = First");
    else
	if (percentage<60 && percentage>=48)
	    printf("Division = Second");
	else
	    if (percentage<48 && percentage>=36)
		printf("Division = Third");
	     else
		printf("Division = Fail");
}

Program to calculate total marks and percentage of a student in C++ language

#include<iostream>
using namespace std;
int main()
{
   int rollNo,marks1,marks2,marks3,total;
    float percentage;
    char name[20];
    cout<<"Enter the Roll Number of the student : ";
    cin>>rollNo;
    cout<<"Enter the Name of the Student : ";
    cin>>name;
    cout<<"Enter the marks of first subject : ";
    cin>>marks1;
    cout<<"Enter the marks of second subject : ";
    cin>>marks2;
    cout<<"Enter the marks of third subject : ";
    cin>>marks3;
    total = marks1+marks2+marks3;
    percentage = total/3.0;
    cout<<"Total marks = "<<total<<endl;
    cout<<"Percentage = "<<percentage<<endl;

    if (percentage>=60)
	 cout<<"Division = First";
    else
	if (percentage<60 && percentage>=48)
	    cout<<"Division = Second";
	else
	    if (percentage<48 && percentage>=36)
		cout<<"Division = Third";
	     else
		cout<<"Division = Fail";
}

Program to calculate total marks and percentage of a student in Python language

rollNo = int(input("Enter student's roll number:  "))
name = input("Enter students name: ")
marks1 = int(input("Enter the marks in first subject:  "))
marks2 = int(input("Enter the marks in second subject:  "))
marks3 = int(input("Enter the marks in third subject:  "))
total = marks1 + marks2 + marks3
percentage = total / 3
print("Total marks= ",total)
print("Percentage= ",percentage,"%")
if (percentage >= 60):
    print("division = First")
elif (percentage >= 50):
    print("division = Second")
elif (percentage >= 40):
    print("division = Third")
else:
    print("division = Fail")

Program to calculate total marks and percentage of a student in Java language

import java.util.Scanner;
  public class StudentMarks {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      System.out.print("Enter student's roll number: ");
      int rollNo = sc.nextInt();
      sc.nextLine();
      System.out.print("Enter students name: ");
      String name = sc.nextLine();
      System.out.print("Enter the marks in first subject: ");
      int marks1 = sc.nextInt();
      System.out.print("Enter the marks in second subject: ");
      int marks2 = sc.nextInt();
      System.out.print("Enter the marks in third subject: ");
      int marks3 = sc.nextInt();

      int total = marks1 + marks2 + marks3;
      double percentage = total / 3.0;
      
     String division = "";

     if (percentage >= 60) {
          division = "First";
         }
     else if (percentage >= 50) {
          division = "Second";
         }
      else if (percentage >= 40) {
          division = "Third";
         }
       else {
          division = "Fail";
         }
System.out.println("Total: " + total);
System.out.println("Percentage: " + percentage + "%");
System.out.println("Division: " + division);
}
}