C# Program To Demonstrate Multilevel Inheritance
C# Program To Demonstrate Multilevel Inheritance
C# Program To Demonstrate Multilevel Inheritance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Inheritance
{
class Program
{
static void Main(string[] args)
{
Teacher d = new Teacher();
d.Teach();
Student s = new Student();
s.Learn();
s.Teach();
Console.ReadKey();
}
class Teacher
{
public void Teach()
{
Console.WriteLine("Teach");
}
}
class Student : Teacher
{
public void Learn()
{
Console.WriteLine("Learn");
}
}
}
}
Output
Output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
public static void Main(string[] args)
{
int m, n,i,j;
Console.Write("Enter Number Of Rows And Columns Of Matrices A and B : ");
m = Convert.ToInt16(Console.ReadLine());
n = Convert.ToInt16(Console.ReadLine());
int[,] A = new int[10, 10];
Console.Write("\nEnter The First Matrix : ");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
A[i, j] = Convert.ToInt16(Console.ReadLine());
}
}
}
Console.WriteLine();
}
Console.WriteLine("\nMatrix B: ");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(B[i, j] + "\t");
}
Console.WriteLine();
}
int[,] C = new int[10, 10];
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
C[i, j] = A[i, j] + B[i, j];
}
}
Console.Write("\nSum Matrix :");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(C[i, j] + "\t");
}
Console.WriteLine();
}
Console.Read();
}
}
}