Program to calculate percentage mark of student

Description

To calculate percentage marks, calculate total mark obtained.
Multiply total obtained mark by 100 and divide it by total marks of exam.

C/C++

/* C Program to calculate percentage mark of student */
//Save it as PercentageMarkStudent.c

#include<stdio.h>
int main(){

    float mark1, mark2, mark3, totalMark, percentageMark;

    printf("Enter the marks in first subject : ");
    scanf("%f",&mark1);

    printf("Enter the marks in second subject : ");
    scanf("%f",&mark2);

    printf("Enter the marks in third subject : ");
    scanf("%f",&mark3);

    //Calculate total mark
    totalMark = mark1 + mark2 + mark3;

    //Calculate percentage mark
    percentageMark = (totalMark*100)/300;

    printf("Percentage mark = %.3f",percentageMark);

    return 0;
}
Input:
Enter the marks in first subject : 50
Enter the marks in second subject : 60
Enter the marks in third subject : 70

Output:
Percentage mark = 60.000

Java

/* Java Program to calculate percentage mark of student */
//Save it as PercentageMarkStudent.java

import java.io.*;
import java.util.Scanner;

public class PercentageMarkStudent {

    public static void main(String[] args) {

            Scanner scanner = new Scanner(System.in);
        
            float mark1, mark2, mark3, totalMark, percentageMark;

        System.out.println("Enter the marks in first subject : ");
        mark1 = scanner.nextFloat();

        System.out.println("Enter the marks in second subject : ");
        mark2 = scanner.nextFloat();

        System.out.println("Enter the marks in third subject : ");
        mark3 = scanner.nextFloat();

            //Calculate total mark
        totalMark = mark1 + mark2 + mark3;
        
            //Calculate percentage mark
        percentageMark = (totalMark*100)/300;

        System.out.println("Percentage mark = "+percentageMark);
    }
}
Input:
Enter the marks in first subject : 
50
Enter the marks in second subject : 
60
Enter the marks in third subject : 
70

Output:
Percentage mark = 60.0

Related Programs

1) Program to find simple interest
2) Program to calculate Gross Salary
3) Program to calculate Grade of Student
4) Program to display multiplication table of a number
5) Program to convert Octal to Decimal
6) Program to find HCF using Recursion
7) Simple Calculator Using If Else
8) Program to calculate Volume and Surface Area of Sphere
9) Program to find greatest of 3 numbers
10) Check whether a given number is a perfect number or not
Share Me

Leave a Reply