Student Results

Design

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Fo
        namespace DataGridview_4_Subject_Fail_Pass
        {
            public partial class Form1 : Form
            {
                int r;
                public Form1()
                {
                    InitializeComponent();
                    r = 0;
                }
                private void button1_Click(object sender, EventArgs e)
                { 
                    dataGridView1.Rows.Add();

                    dataGridView1[0, r].Value = textBox1.Text;
                    dataGridView1[1, r].Value = textBox2.Text;
                    dataGridView1[2, r].Value = textBox3.Text;
                    dataGridView1[3, r].Value = textBox4.Text;

                    dataGridView1[4, r].Value = (Convert.ToInt16(textBox1.Text) + Convert.ToInt16(textBox2.Text) + Convert.ToInt16(textBox3.Text)+Convert.ToInt16(textBox4.Text)).ToString();

                    dataGridView1[5, r].Value = (Convert.ToInt16(dataGridView1[4, r].Value) / 4).ToString();
                   
                    if (Convert.ToInt16(dataGridView1[6,r].Value) > 35)
                    {
                        dataGridView1[6, r].Value = "Pass";
                    }
                    else
                    {
                        dataGridView1[6, r].Value = "Fail";
                    }
                    r++;
                }
            }
        }    
                

Output