Professional Documents
Culture Documents
Karachi Campus
Submitted By:
____Zain Rizvi________________________46064_______
(Name) (Reg. No.)
Submitted To:
1
[Lab no.10] [Computer Programming]
[2D-Array]
Signed Remarks: Score:
Bahria University,
Karachi Campus
Submitted On:
12/ dec /2020
(Date: DD/MM/YY)
[Lab no.10] [Computer Programming]
[2D Arrays]
Task No. 1: Enter the first matrix and then display it. Secondly, enter the second matrix and
then display it. In the result by apply 2D arrays show Addition, subtraction of 2 matrixes.
Solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace lab_10
{
class matrix_add
{
public void add()
{
Console.WriteLine("Input Matrix 1");
int[,] matrix1 = new int[3, 3];
}
}
}
}
}
Output:
[Lab no.10] [Computer Programming]
[2D-Array]
Task No 2: Take N number of user data input and make sure N is greater than 10, which
contain name of the user, his/her nationality and his/her eye color. You have to show the max
Solution:
class task2
{
public void task() {
string[] head = new string[3];
string[,] matrix = new string[11, 3];
string[] matrix1 = new string[5];
int[] mat2 = new int[5];
matrix1[0] = "Pakistan";
matrix1[1] = "India";
matrix1[2] = "Korea";
matrix1[3] = "Canada";
matrix1[4] = "Us";
head[0] = "Name:";
head[1] = "Nationality:";
head[2] = "eye color:";
for (int i = 0; i < 11; i++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(head[j] + " ");
matrix[i,j] = Console.ReadLine();
}
Console.WriteLine("\n\n");
}
Console.WriteLine();
}
Console.ReadKey();
[Lab no.10] [Computer Programming]
[2D-Array]
}
}
Output:
[Lab no.10] [Computer Programming]
[2D-Array]
Task 3: Make a program in C# in which take no. of items, price of items,quantity of items and name of items
as input from the user and give the discount according to the following conditions (Use 2D Array):
Solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace lab_10
{
class task3
{
public void t3()
{
Console.Write("Enter number of items");
//3. Make a program in C# in which take no. of items,
// price of items,
// quantity of items and name of items as input from the user and give the
discount according to the following conditions
int i = Convert.ToInt16(Console.ReadLine());
}
Console.WriteLine();
}
Console.Write("Total=" + total);
Console.ReadKey();
}
}
}
Output:
[Lab no.10] [Computer Programming]
[2D-Array]