Console Application-Use of Structure


 

public struct student

{

        public int rollno;

        public int m1;

        public int m2;

        public int m3;

        public int tot;

        public double per;

        public string name;

}

 

 

public void Main()

{

        student[] s = new student[2];

        int i = 0;

        for (i = 1; i <= 1; i++) {

               Console.WriteLine("Enter the Roll Number of Student:=>");

               s[i].rollno = Console.ReadLine();

               Console.WriteLine("Enter the Name of Student:=>");

               s[i].name = Console.ReadLine();

               Console.WriteLine("Enter the Marks of First Subject:=>");

               s[i].m1 = Console.ReadLine();

               Console.WriteLine("Enter the Marks of Second Subject:=>");

               s[i].m2 = Console.ReadLine();

               Console.WriteLine("Enter the Marks of Third Subject:=>");

               s[i].m3 = Console.ReadLine();

               s[i].tot = s[i].m1 + s[i].m2 + s[i].m3;

               Console.WriteLine("Roll No:=>" + s[i].rollno);

               Console.WriteLine("Name:=>" + s[i].name);

               Console.WriteLine("Total:=>" + s[i].tot);

               s[i].per = s[i].tot / 3;

               Console.WriteLine("Percentage:=>" + s[i].per);

        }

 

        Console.ReadLine();

}


Ebook Download
View all
Learn
View all