C# Program to Generate the Marksheet of the Student


This is a C# Program to generate the marksheet of the student.

Problem Description

This C# Program Generates the Marksheet of the Student.

Problem Solution

Here the student details are obtained from the user and the marksheet is generated based on the details.

Program/Source Code

Here is source code of the C# Program to Generate the Marksheet of the Student. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

 * C# Program to Generate the Marksheet of the Student
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Marksheet1
    class Program
        static void Main(string[] args)
            int r, m1, m2, m3, t;
            float p;
            string n;
            Console.WriteLine("Enter Roll Number :");
            r = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Student Name :");
            n = Console.ReadLine();
            Console.WriteLine("Mark of Subject1 : ");
            m1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Mark of Subject2 : ");
            m2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Mark of Subject3 : ");
            m3 = Convert.ToInt32(Console.ReadLine());
            t = m1 + m2 + m3;
            p = t / 3.0f;
            Console.WriteLine("Total : " + t);
            Console.WriteLine("Percentage : " + p);
            if (p >= 35 && p < 50)
                Console.WriteLine("Grade is C");
            if (p >= 50 && p <= 60)
                Console.WriteLine("Grade is B");
            if (p > 60 && p <= 80)
                Console.WriteLine("Grade is A");
            if (p > 80 && p <= 100)
                Console.WriteLine("Grade is A+");
Program Explanation

In this C# program, we are reading the Roll Number, Student Name, Mark of Subject1, Mark of Subject2, and Mark of Subject3 using ‘r’, ‘n’, ‘m1’, ‘m2’ and ‘m3’ variables respectively.

Note: Join free Sanfoundry classes at Telegram or Youtube

Compute the summation of total marks obtained by the user in three subjects. Divide the total marks in all the subjects by total number of subjects to compute the average. Print the student details obtained from the user and generate the marksheet based on the details.

Runtime Test Cases
Enter RollNumber : 
Enter Student Name :
Mark of Subject1 :
Mark of Subject2 :
Mark of Subject3 :
Total : 240
Percentage : 80
Grade is A

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

Take C# Programming Mock Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
If you wish to look at all C# Programming examples, go to 1000 C# Programs.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.