Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

5.Write a program to implement multilevel inheritance.

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication5

{

class student

{

int rollno;

public void getrollno(int r)

{

rollno=r;

}

public void putrollno()

{

Console.WriteLine("The student Roll No is="+rollno);

}

}

class test : student

{

public float m1,m2;

public void getmarks(float x,float y)

{

m1=x;

m2=y;

}

public void putmarks()

{

Console.WriteLine("Marks obtained in sub1=" +m1);

Console.WriteLine("Marks obtained in sub2=" +m2);

}}

class result : test

{

float total;

public void display()

{

total=m1+m2;

Console.WriteLine("Total marks is="+total);

}

}

class multi

{

public static void Main()

{

result res=new result();

res.getrollno(100);

res.getmarks(99.65f, 85.12f);

res.putrollno();

res.putmarks();

res.display();

Console.ReadLine();

}

}

}

Post a Comment

0 Comments