# Write C# Program to calculate the total marks, percentage and division of student based on three subjects

C#, also known as C Sharp, is a programming language that was developed by Microsoft in 2000. It is a modern, object-oriented language that is designed for the development of Windows applications, web services, and other types of software. C# is known for its simplicity and ease of use, making it a popular choice among developers of all skill levels.

Introduction to Calculating the Total Marks Percentage and Division of a Student

Calculating the total marks percentage and division of a student based on their marks in three subjects is an important task for educators and administrators. This information is used to determine a student’s overall performance and progress in their studies. In this article, we will be discussing how to write a C# program to calculate the total marks percentage and division of a student based on their marks in three subjects.

Coding the Program

The first step in creating a C# program to calculate the total marks percentage and division of a student is to define the variables that will be used in the program. In this case, we will be using the following variables:

• int marks1, marks2, marks3: These variables will be used to store the marks of the student in each of the three subjects.
• int total: This variable will be used to store the total marks of the student in all three subjects.
• float percentage: This variable will be used to store the percentage of marks that the student has scored in all three subjects.
• string division: This variable will be used to store the division of the student based on their percentage of marks.
``````int marks1, marks2, marks3;

int total;

float percentage;

string division;``````

Once the variables have been defined, we can begin writing the code for the program. The first step is to input the marks of the student in each of the three subjects. This can be done using the following code:

``````Console.WriteLine("Enter the marks of the student in subject 1: ");

marks1 = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the marks of the student in subject 2: ");

marks2 = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the marks of the student in subject 3: ");

marks3 = int.Parse(Console.ReadLine());``````

Next, we will calculate the total marks of the student in all three subjects. This can be done using the following code:

total = marks1 + marks2 + marks3;

Once we have the total marks, we can calculate the percentage of marks that the student has scored in all three subjects. This can be done using the following code:

percentage = (total / 300) * 100;

Finally, we will determine the division of the student based on their percentage of marks. This can be done using the following code:

``````if (percentage >= 60) {

division = "First Division";

} else if (percentage >= 45) {

division = "Second Division";

} else {

division = "Third Division";

}``````

Source code

``````using System;

public class HelloWorld

{

public static void Main(string[] args)

{

int marks1, marks2, marks3;

int total;

float percentage;

string division;

Console.WriteLine("Enter the marks of the student in subject 1: ");

marks1 = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the marks of the student in subject 2: ");

marks2 = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the marks of the student in subject 3: ");

marks3 = int.Parse(Console.ReadLine());

total = marks1 + marks2 + marks3;

percentage = (total / 300) * 100;

if (percentage >= 60) {

division = "First Division";

} else if (percentage >= 45) {

division = "Second Division";

} else {

division = "Third Division";

}

}

}``````

Explanation of the Code

The first step in the code is to input the marks of the student in each of the three subjects. This is done using the Console.WriteLine() method, which is used to display a message on the screen. The Console.ReadLine() method is used to read the input from the user and store it in the respective variables.

Next, we calculate the total marks of the student in all three subjects. This is done by simply adding the marks of the student in each of the three subjects.

Once we have the total marks, we can calculate the percentage of marks that the student has scored in all three subjects. This is done by dividing the total marks by 300 (the maximum marks possible in all three subjects) and multiplying the result by 100. This gives us the percentage of marks that the student has scored.

Finally, we determine the division of the student based on their percentage of marks. This is done using an if-else statement, which checks the value of the percentage variable. If the percentage is greater than or equal to 60, the student is in the First Division. If the percentage is greater than or equal to 45 but less than 60, the student is in the Second Division. If the percentage is less than 45, the student is in the Third Division.

Results and Conclusion

Using the code provided in this article, educators and administrators can easily calculate the total marks percentage and division of a student based on their marks in three subjects. This information is crucial for determining a student’s overall performance and progress in their studies. By using C# to create this program, we have made the process of calculating student marks easy, efficient and accurate. With the use of proper variables and conditional statements, one can easily understand the logic and use the code to create their own program. In conclusion, this program is a great tool for educators and administrators to use in order to keep track of student performance and progress in their studies.

Taggedpercentage and division of student based on three subjectsWrite C# Program to calculate the total marks

### Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

### C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …