SlideShare a Scribd company logo
1 of 34
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 2 : EX.NO-1 Matrix addition subtraction multiplication
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
class matadd
{
int[,] A = new int[10, 10];
int[,] B = new int[10, 10];
int[,] C = new int[10, 10];
int[,] D = new int[10, 10];
int m, n, i, j;
public void input()
{
Console.WriteLine("Enter the Number of Rows and Columns");
m = Convert.ToInt16(Console.ReadLine());
n = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Enter the first Matrix value");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
A[i, j] = Convert.ToInt16(Console.ReadLine());
}
}
Console.WriteLine("ENter the Second Matrix value");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
B[i, j] = Convert.ToInt16(Console.ReadLine());
}
}
Console.Clear();
}
public void add()
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
Console.WriteLine("nMatrix value of A:");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(A[i, j] + "t");
}
Console.WriteLine();
}
Console.WriteLine("nMatrix value of B:");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(B[i, j] + "t");
}
Console.WriteLine();
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
C[i, j] = A[i, j] + B[i, j];
}
}
Console.WriteLine("nMatrix Addition");
Console.WriteLine("~~~~~~~~~~~~~~~~~");
// Console.WriteLine("The Addition of Two matrix is:");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(C[i,j]+"t");
}
Console.WriteLine();
}
}
public void sub()
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("nMatrix Subtraction");
Console.WriteLine("~~~~~~~~~~~~~~~~~");
/*Console.WriteLine("nMatrix value of A:");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(A[i, j] + "t");
}
Console.WriteLine();
}
Console.WriteLine("nMatrix value of B:");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(B[i, j] + "t");
}
Console.WriteLine();
}*/
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
C[i, j] = A[i, j] - B[i, j];
}
}
Console.WriteLine("The Subtraction of Two matrix is:");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(C[i, j] + "t");
}
Console.WriteLine();
}
}
public void mul()
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("nMatrix Multiplication");
Console.WriteLine("~~~~~~~~~~~~~~~~~");
Console.WriteLine("nMatrix value of A:");
/*for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(A[i, j] + "t");
}
Console.WriteLine();
}
Console.WriteLine("nMatrix value of B:");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(B[i, j] + "t");
}
Console.WriteLine();
}*/
D[i, j] = 1;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
D[i, j] *= A[i, j] + B[i, j];
} }
Console.WriteLine("The Multiplication of Two matrix is:");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(D[i, j] + "t") }
Console.WriteLine();
} } }
class matrix
{ static void Main(string[] args)
{ matadd ma = new matadd();
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
ma.input();
ma.add();
ma.sub();
ma.mul();
Console.ReadLine(); } } }
Output:Matrix value of A:
1 2
5 2
Matrix value of B:
3 6
8 4
Matrix Addition
~~~~~~~~~~~~~~~~~
4 8
13 6
Matrix Subtraction
~~~~~~~~~~~~~~~~~
The Subtraction of Two matrix is:
-2 -4
-3 -2
Matrix Multiplication
~~~~~~~~~~~~~~~~~
Matrix value of A:The Multiplication of Two matrix is:
0 0
0 0
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 2 : EX.NO-2 INVERSION OF MATRIX
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication25
{
class matadd
{
int[,] A = new int[10, 10];
int i, j, m, n;
float determinant = 0;
public void input()
{
Console.WriteLine("Enter the Number of Rows and Columns");
m = Convert.ToInt16(Console.ReadLine());
n = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Enter the first Matrix value");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
A[i, j] = Convert.ToInt16(Console.ReadLine());
}
}
}
public void add()
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("nMatrix value of A:");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(A[i, j] + "t");
}
Console.WriteLine();
}
for (i = 0; i < 3; i++)
determinant = determinant + (A[0, i] * (A[1, (i + 1) % 3] * A[2, (i + 2) %
3] - A[1, (i + 2) % 3] * A[2, (i + 2) % 3]));
Console.WriteLine("Inverse of matrix is");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
Console.Write("{0}t", ((A[(i + 1) % 3, (j + 1) % 3] * A[(i + 2) % 3, (j
+ 2) % 3]) - (A[(i + 1) % 3, (j + 2) % 3] * A[(i + 2) % 3, (j + 1) % 3])) /
determinant);
}
Console.WriteLine();
}
}
}
class matrix
{
static void Main(string[] args)
{
int ch;
do
{
Console.WriteLine("Inverse of the Matrix");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~");
matadd ma = new matadd();
ma.input();
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
ma.add();
Console.WriteLine("Do you want to continue Press(1/0)");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 2 : EX.NO-3 REVERSE ORDER
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication20
{
class rever
{
int[] a = new int[10];
int n;
public void input()
{
Console.WriteLine("Enter the Number of Elements");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Values");
for (int i = 0; i < n; i++)
{
Console.Write("Number[{0}]=", i);
a[i] = int.Parse(Console.ReadLine());
}
}
public void rev()
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (a[i] > a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
}
Console.WriteLine("Reverse of Given Number:");
for (int i = 0; i < n; i++)
{
Console.Write("Number[{0}]=",i);
Console.WriteLine(a[i]);
}
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
rever r = new rever();
Console.WriteLine("Reverse of Given Elements");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~");
r.input();
r.rev();
Console.WriteLine("Do You want to perform again Press(1/0)");
ch = int.Parse(Console.ReadLine());
}
while (ch == 1);
Console.ReadLine();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Output:
Reverse of Given Elements
~~~~~~~~~~~~~~~~~~~~~~~~~
Enter the Number of Elements
5
Enter the Values
Number[0]=2
Number[1]=4
Number[2]=5
Number[3]=1
Number[4]=23
Reverse of Given Number:
Number[0]=23
Number[1]=5
Number[2]=4
Number[3]=2
Number[4]=1
Do You want to perform again Press(1/0)
0
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST -2 : EX.NO-4 BIGGEST,LOWESTELEMENTS OF AN ARRAY
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication20
{
class rever
{
int[] a = new int[10];
int n;
public void input()
{
Console.WriteLine("Enter the Number of Elements");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Values");
for (int i = 0; i < n; i++)
{
Console.Write("Number[{0}]=", i);
a[i] = int.Parse(Console.ReadLine());
}
}
public void rev()
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (a[i] < a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("Lower to Higher Order");
for (int i = 0; i < n; i++)
{
Console.Write("Number[{0}]=", i);
Console.WriteLine(a[i]);
}
Console.Write("Smallest Element is");
Console.WriteLine(a[0]);
Console.Write("Largest Element is ");
Console.WriteLine(a[n-1]);
}
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
rever r = new rever();
Console.WriteLine("Biggest and lowest of Given Elements in array");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~");
r.input();
r.rev();
Console.WriteLine("Do You want to perform again Press(1/0)");
ch = int.Parse(Console.ReadLine());
}
while (ch == 1);
Console.ReadLine();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Output:
Biggest and lowest of Given Elements in array
~~~~~~~~~~~~~~~~~~~~~~~~~
Enter the Number of Elements
5
Enter the Values
Number[0]=3
Number[1]=56
Number[2]=2
Number[3]=6
Number[4]=3
Lower to Higher Order
Number[0]=2
Number[1]=3
Number[2]=3
Number[3]=6
Number[4]=56
Smallest Element is2
Largest Element is 56
Do You want to perform again Press(1/0)
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LAB LIST - 2 : EX.NO-5 SWAPPING OF TWO ARRAY
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication13
{
classswaping
{
int[] a = newint[10];
int[] b = newint[10];
int[] c = newint[10];
int i, n;
publicvoid input()
{
Console.WriteLine("enter of no of elements");
n = int.Parse(Console.ReadLine());
Console.WriteLine("enter first array---->");
for (int i = 0; i < n; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("_______________");
Console.WriteLine("enter second array elements---->");
for (i = 0; i <= n; i++)
{
b[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("_________________");
}
publicvoid display()
{
Console.WriteLine("BEFORE swaPping two arrays");
Console.WriteLine("first array");
for (int i = 0; i < n; i++)
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
Console.WriteLine(a[i]);
}
Console.WriteLine("_________________");
Console.WriteLine("second arrray");
for(int i=0;i<n;i++)
{
Console.WriteLine(b[i]);
}
//swapping
for(i=0;i<n;i++)
{
c[i]=a[i];
a[i]=b[i];
b[i]=c[i];
}
Console.WriteLine("AFTER swap");
Console.WriteLine("first array");
for(i=0;i<n;i++)
{
Console.WriteLine(a[i]);
}
Console.WriteLine("second array");
for(i=0;i<n;i++)
{
Console.WriteLine(b[i]);
}
Console.WriteLine("_________________");
}
}
classsub_swapping
{
publicstaticvoid Main(string[] args)
{
int ch;
do
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
swaping sw = newswaping();
sw.input();
sw.display();
Console.WriteLine("do u wanto conntinue(1) or (0)");
ch = int.Parse(Console.ReadLine());
} while (ch == 1);
}
}
}
Output:
enter of no of elements
4
enter first array---->
5
23
1
67
_______________
enter second array elements---->
2
3
42
12
12
_________________
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
BEFORE swapping two arrays
first array
5
23
1
67
_________________
secondarrray
2
3
42
12
AFTER swap
first array
2
3
42
12
second array
5
23
1
67
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
_________________
LABLIST - 2 : EX.NO-6 Ascending and desceding order of number
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication19
{
class ascdes
{
int n;
int[] a = new int[10];
public void input()
{
Console.WriteLine("Enter the Number");
n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.Write("Number[{0}]=", i);
a[i] = int.Parse(Console.ReadLine());
}
}
public void asc()
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (a[i] < a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.WriteLine("Ascending Order of Given Number:");
for (int i = 0; i < n; i++)
{
Console.WriteLine(a[i]);
}
}
public void des()
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (a[i] > a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
Console.WriteLine("Descending Order of Given Number:");
for (int i = 0; i < n; i++)
{
Console.WriteLine(a[i]); } } }
class Program
{ static void Main(string[] args)
{ int ch;
do
{
ascdes a = new ascdes();
Console.WriteLine("Ascending And Descending Order");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
a.input();
a.asc();
a.des();
Console.WriteLine("Do You want to perform again Press(1/0)");
ch = int.Parse(Console.ReadLine());
}
while (ch == 1);
Console.ReadLine();
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
} } }
OUTPUT: Ascending And Descending Order
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter the Number 6
Number[0]=2
Number[1]=4
Number[2]=6
Number[3]=2
Number[4]=8
Number[5]=78
Ascending Order of Given Number:
2
2
4
6
8
78 Descending Order of Given Number:
78
8
6
4
2
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
2
LAB LIST - 2 : EX.NO-7 SUM OF DIAGONAL IN A MATRIX
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Text;
class mat
{
int i, j, m, n;
int[,] a = new int[20, 20];
public void get()
{
Console.WriteLine("Enter Row Value");
m = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Column Value");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Elements one by one");
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
a[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine("Given Matrix");
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
Console.Write("t{0}", a[i, j]);
}
Console.WriteLine();
}
}
public void diag()
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
int d;
d = 0;
if (m == n)
{
for (i = 1; i <= m; i++)
{
for (j = 1; j <= n; j++)
{
if (i == j)
{
d = d + a[i, j];
}
}
}
Console.WriteLine("Diagonal Sum= {0}", d);
}
else
{
Console.WriteLine("Can't Perform Diagonal Sum");
}
}
class matsum
{
static void Main(string[] args)
{
mat ma = new mat();
ma.get();
ma.diag();
Console.Read();
}
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:2 EX.NO-8 LARGEST AND SMALLEST VALUES OF MATRIX
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication16
{
classrever
{
int[,] mat= newint[10,10];
int i,j,row,col,small,big;
publicvoid input()
{
Console.WriteLine("Enter the Number of Rows and Columns");
row = int.Parse(Console.ReadLine());
col = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Element of the Matrix");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
mat[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine("Elements in a Matrix");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.Write(mat[i,j]+"t");
}
Console.WriteLine();
}
}
publicvoid min()
{
big=mat[0,0];
small=mat[0,0];
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if(mat[i,j]<small)
small=mat[i,j];
if(mat[i,j]>big)
big=mat[i,j];
}
}
Console.WriteLine("Smallest Element in a Matrix={0}",small);
Console.WriteLine("Largest Element in a Matrix={0}",big);
}
}
classProgram
{
staticvoid Main(string[] args)
{
int ch;
do
{
rever r = newrever();
Console.WriteLine("Find Smallest And Largest value of a MAtrix");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
r.input();
r.min();
Console.WriteLine("Do You want to perform again Press(1/0)");
ch = int.Parse(Console.ReadLine());
}
while (ch == 1);
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Console.ReadLine();
}
}
}
Output:
Find Smallest And Largest value of a MAtrix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter the Number of Rows and Columns
3
3
Enter the Element of the Matrix
2
2
2
234
12
6
7
1
78
Elements in a Matrix
2 2 2
234 12 6
7 1 78
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Smallest Element in a Matrix=1
Largest Element in a Matrix=234
Lab List - 2 : EX.NO-9 NPR and NCR(Permitation and combination)
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication7
{
classncr
{
publicvoid ncr_met()
{
int n, r, per, fact, fact1, fact2;
Console.WriteLine("calculate NCR values");
Console.WriteLine("Enter the Value of 'n' and 'r' to find the Permutation :");
n = Convert.ToInt32(Console.ReadLine());
r = Convert.ToInt32(Console.ReadLine());
fact = n;
for (int i = n - 1; i >= 1; i--)
{
fact = fact * i;
}
fact2 = r;
for (int i = r - 1; i >= 1; i--)
{
fact2 = fact2 * i;
}
int number;
number = n - r;
fact1 = number;
for (int i = number - 1; i >= 1; i--)
{
fact1 = fact1 * i;
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
fact1 = fact2 * fact1;
per = fact / fact1;
Console.WriteLine("Combination : {0}", per);
}
publicvoid pnr_method()
{
int n, r, per, fact, fact1;
Console.WriteLine("Calculate NPR values");
Console.WriteLine("Enter the Value of 'n' and 'r' to find the Permutation :");
n = Convert.ToInt32(Console.ReadLine());
r = Convert.ToInt32(Console.ReadLine());
fact = n;
for (int i = n - 1; i >= 1; i--)
{
fact = fact * i;
}
int number;
number = n - r;
fact1 = number;
for (int i = number - 1; i >= 1; i--)
{
fact1 = fact1 * i;
}
per = fact / fact1;
Console.WriteLine("Permutation : {0}", per);
}
}
classsu_method
{
publicstaticvoid Main(string[] args)
{
int ch;
do
{
ncr np = newncr();
np.ncr_met();
np.pnr_method();
Console.WriteLine("do u want to continue(1) or (0)");
ch = Int32.Parse(Console.ReadLine());
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
}
while (ch == 1);
Console.ReadLine();
}
}
}
OUPUT:
calculate NCR values
Enter the Value of 'n' and 'r' to find the Permutation :
4
5
Combination : 0
Calculate NPR values
Enter the Value of 'n' and 'r' to find the Permutation :
12
23
Permutation : -43545600
do u want to continue(1) or (0)
1
calculate NCR values
Enter the Value of 'n' and 'r' to find the Permutation :
5
4
Combination : 5
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Calculate NPR values
Enter the Value of 'n' and 'r' to find the Permutation :
2
1
Permutation : 2
do u want to continue(1) or (0)
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Lab List - 2 : EX.NO-10 LCM and GCD OF GIVEN NUMBER
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication14
{
classpro_lcm
{
int a,b,n1,n2,swap,lcm,gcd;
publicvoid input()
{
Console.WriteLine("Enter the Number");
a = Int32.Parse(Console.ReadLine());
b = Int32.Parse(Console.ReadLine());
}
publicvoid calc()
{
n1 = a;
n2 = b;
while (n2 != 0)
{
swap= n2;
n2 = n1 % n2;
n1 = swap;
}
gcd=n1;
lcm = (a * b) / gcd;
Console.WriteLine("lcm of {0} and {1}is {2}", a, b, lcm);
Console.WriteLine("gcd of {0} and {1} is {2}", a, b, gcd);
}
}
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
classpro
{
publicstaticvoid Main(string[] args)
{
int ch;
do
{
pro_lcm pl = newpro_lcm();
pl.input();
pl.calc();
Console.WriteLine("do u want to continue(1) or(0)");
ch = Int32.Parse(Console.ReadLine());
} while (ch == 1);
}
}
}
OUTPUT:
Enter the Number
45
50
lcm of 45 and 50is 450
gcd of 45 and 50 is 5
do u want to continue(1) or(0)
SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment

More Related Content

What's hot

What's hot (20)

Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
syed
syedsyed
syed
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Insertion Sort Code
Insertion Sort CodeInsertion Sort Code
Insertion Sort Code
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diploma
 
The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88The Ring programming language version 1.3 book - Part 83 of 88
The Ring programming language version 1.3 book - Part 83 of 88
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in Scala
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
C program
C programC program
C program
 
Hems
HemsHems
Hems
 

Similar to .net progrmming part2

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...MaruMengesha
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And EnumsBhushan Mulmule
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answersQuratulain Naqvi
 

Similar to .net progrmming part2 (20)

Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
C#.net
C#.netC#.net
C#.net
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And Enums
 
Los dskn
Los dsknLos dskn
Los dskn
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 

More from Dr.M.Karthika parthasarathy

IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...Dr.M.Karthika parthasarathy
 
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxDr.M.Karthika parthasarathy
 

More from Dr.M.Karthika parthasarathy (20)

IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
 
Linux Lab Manual.doc
Linux Lab Manual.docLinux Lab Manual.doc
Linux Lab Manual.doc
 
Unit 2 IoT.pdf
Unit 2 IoT.pdfUnit 2 IoT.pdf
Unit 2 IoT.pdf
 
Unit 3 IOT.docx
Unit 3 IOT.docxUnit 3 IOT.docx
Unit 3 IOT.docx
 
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptx
 
Unit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docxUnit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docx
 
Introduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptxIntroduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptx
 
IoT Unit 2.pdf
IoT Unit 2.pdfIoT Unit 2.pdf
IoT Unit 2.pdf
 
Chapter 3 heuristic search techniques
Chapter 3 heuristic search techniquesChapter 3 heuristic search techniques
Chapter 3 heuristic search techniques
 
Ai mcq chapter 2
Ai mcq chapter 2Ai mcq chapter 2
Ai mcq chapter 2
 
Introduction to IoT unit II
Introduction to IoT  unit IIIntroduction to IoT  unit II
Introduction to IoT unit II
 
Introduction to IoT - Unit I
Introduction to IoT - Unit IIntroduction to IoT - Unit I
Introduction to IoT - Unit I
 
Internet of things Unit 1 one word
Internet of things Unit 1 one wordInternet of things Unit 1 one word
Internet of things Unit 1 one word
 
Unit 1 q&amp;a
Unit  1 q&amp;aUnit  1 q&amp;a
Unit 1 q&amp;a
 
Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1
 
Examples in OS synchronization for UG
Examples in OS synchronization for UG Examples in OS synchronization for UG
Examples in OS synchronization for UG
 
Process Synchronization - Monitors
Process Synchronization - MonitorsProcess Synchronization - Monitors
Process Synchronization - Monitors
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
.net progrmming part3
.net progrmming part3.net progrmming part3
.net progrmming part3
 
Java programs
Java programsJava programs
Java programs
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

.net progrmming part2

  • 1. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 2 : EX.NO-1 Matrix addition subtraction multiplication SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication10 { class matadd { int[,] A = new int[10, 10]; int[,] B = new int[10, 10]; int[,] C = new int[10, 10]; int[,] D = new int[10, 10]; int m, n, i, j; public void input() { Console.WriteLine("Enter the Number of Rows and Columns"); m = Convert.ToInt16(Console.ReadLine()); n = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("Enter the first Matrix value"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { A[i, j] = Convert.ToInt16(Console.ReadLine()); } } Console.WriteLine("ENter the Second Matrix value"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { B[i, j] = Convert.ToInt16(Console.ReadLine()); } } Console.Clear(); } public void add()
  • 2. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment { Console.WriteLine("nMatrix value of A:"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(A[i, j] + "t"); } Console.WriteLine(); } Console.WriteLine("nMatrix value of B:"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(B[i, j] + "t"); } Console.WriteLine(); } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { C[i, j] = A[i, j] + B[i, j]; } } Console.WriteLine("nMatrix Addition"); Console.WriteLine("~~~~~~~~~~~~~~~~~"); // Console.WriteLine("The Addition of Two matrix is:"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { Console.Write(C[i,j]+"t"); } Console.WriteLine(); } } public void sub() {
  • 3. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("nMatrix Subtraction"); Console.WriteLine("~~~~~~~~~~~~~~~~~"); /*Console.WriteLine("nMatrix value of A:"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(A[i, j] + "t"); } Console.WriteLine(); } Console.WriteLine("nMatrix value of B:"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(B[i, j] + "t"); } Console.WriteLine(); }*/ for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { C[i, j] = A[i, j] - B[i, j]; } } Console.WriteLine("The Subtraction of Two matrix is:"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { Console.Write(C[i, j] + "t"); } Console.WriteLine(); } } public void mul() {
  • 4. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("nMatrix Multiplication"); Console.WriteLine("~~~~~~~~~~~~~~~~~"); Console.WriteLine("nMatrix value of A:"); /*for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(A[i, j] + "t"); } Console.WriteLine(); } Console.WriteLine("nMatrix value of B:"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(B[i, j] + "t"); } Console.WriteLine(); }*/ D[i, j] = 1; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { D[i, j] *= A[i, j] + B[i, j]; } } Console.WriteLine("The Multiplication of Two matrix is:"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { Console.Write(D[i, j] + "t") } Console.WriteLine(); } } } class matrix { static void Main(string[] args) { matadd ma = new matadd();
  • 5. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment ma.input(); ma.add(); ma.sub(); ma.mul(); Console.ReadLine(); } } } Output:Matrix value of A: 1 2 5 2 Matrix value of B: 3 6 8 4 Matrix Addition ~~~~~~~~~~~~~~~~~ 4 8 13 6 Matrix Subtraction ~~~~~~~~~~~~~~~~~ The Subtraction of Two matrix is: -2 -4 -3 -2 Matrix Multiplication ~~~~~~~~~~~~~~~~~ Matrix value of A:The Multiplication of Two matrix is: 0 0 0 0
  • 6. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 2 : EX.NO-2 INVERSION OF MATRIX SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication25 { class matadd { int[,] A = new int[10, 10]; int i, j, m, n; float determinant = 0; public void input() { Console.WriteLine("Enter the Number of Rows and Columns"); m = Convert.ToInt16(Console.ReadLine()); n = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("Enter the first Matrix value"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { A[i, j] = Convert.ToInt16(Console.ReadLine()); } } } public void add() {
  • 7. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("nMatrix value of A:"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write(A[i, j] + "t"); } Console.WriteLine(); } for (i = 0; i < 3; i++) determinant = determinant + (A[0, i] * (A[1, (i + 1) % 3] * A[2, (i + 2) % 3] - A[1, (i + 2) % 3] * A[2, (i + 2) % 3])); Console.WriteLine("Inverse of matrix is"); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { Console.Write("{0}t", ((A[(i + 1) % 3, (j + 1) % 3] * A[(i + 2) % 3, (j + 2) % 3]) - (A[(i + 1) % 3, (j + 2) % 3] * A[(i + 2) % 3, (j + 1) % 3])) / determinant); } Console.WriteLine(); } } } class matrix { static void Main(string[] args) { int ch; do { Console.WriteLine("Inverse of the Matrix"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~"); matadd ma = new matadd(); ma.input();
  • 8. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment ma.add(); Console.WriteLine("Do you want to continue Press(1/0)"); ch = int.Parse(Console.ReadLine()); Console.ReadLine(); } while (ch == 1); } } } OUTPUT:
  • 9. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 2 : EX.NO-3 REVERSE ORDER SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication20 { class rever { int[] a = new int[10]; int n; public void input() { Console.WriteLine("Enter the Number of Elements"); n = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the Values"); for (int i = 0; i < n; i++) { Console.Write("Number[{0}]=", i); a[i] = int.Parse(Console.ReadLine()); } } public void rev() { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } }
  • 10. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment } Console.WriteLine("Reverse of Given Number:"); for (int i = 0; i < n; i++) { Console.Write("Number[{0}]=",i); Console.WriteLine(a[i]); } } } class Program { static void Main(string[] args) { int ch; do { rever r = new rever(); Console.WriteLine("Reverse of Given Elements"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~"); r.input(); r.rev(); Console.WriteLine("Do You want to perform again Press(1/0)"); ch = int.Parse(Console.ReadLine()); } while (ch == 1); Console.ReadLine(); } } }
  • 11. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Output: Reverse of Given Elements ~~~~~~~~~~~~~~~~~~~~~~~~~ Enter the Number of Elements 5 Enter the Values Number[0]=2 Number[1]=4 Number[2]=5 Number[3]=1 Number[4]=23 Reverse of Given Number: Number[0]=23 Number[1]=5 Number[2]=4 Number[3]=2 Number[4]=1 Do You want to perform again Press(1/0) 0
  • 12. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST -2 : EX.NO-4 BIGGEST,LOWESTELEMENTS OF AN ARRAY SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication20 { class rever { int[] a = new int[10]; int n; public void input() { Console.WriteLine("Enter the Number of Elements"); n = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the Values"); for (int i = 0; i < n; i++) { Console.Write("Number[{0}]=", i); a[i] = int.Parse(Console.ReadLine()); } } public void rev() { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] < a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } }
  • 13. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("Lower to Higher Order"); for (int i = 0; i < n; i++) { Console.Write("Number[{0}]=", i); Console.WriteLine(a[i]); } Console.Write("Smallest Element is"); Console.WriteLine(a[0]); Console.Write("Largest Element is "); Console.WriteLine(a[n-1]); } } class Program { static void Main(string[] args) { int ch; do { rever r = new rever(); Console.WriteLine("Biggest and lowest of Given Elements in array"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~"); r.input(); r.rev(); Console.WriteLine("Do You want to perform again Press(1/0)"); ch = int.Parse(Console.ReadLine()); } while (ch == 1); Console.ReadLine(); } } }
  • 14. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Output: Biggest and lowest of Given Elements in array ~~~~~~~~~~~~~~~~~~~~~~~~~ Enter the Number of Elements 5 Enter the Values Number[0]=3 Number[1]=56 Number[2]=2 Number[3]=6 Number[4]=3 Lower to Higher Order Number[0]=2 Number[1]=3 Number[2]=3 Number[3]=6 Number[4]=56 Smallest Element is2 Largest Element is 56 Do You want to perform again Press(1/0)
  • 15. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LAB LIST - 2 : EX.NO-5 SWAPPING OF TWO ARRAY SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication13 { classswaping { int[] a = newint[10]; int[] b = newint[10]; int[] c = newint[10]; int i, n; publicvoid input() { Console.WriteLine("enter of no of elements"); n = int.Parse(Console.ReadLine()); Console.WriteLine("enter first array---->"); for (int i = 0; i < n; i++) { a[i] = int.Parse(Console.ReadLine()); } Console.WriteLine("_______________"); Console.WriteLine("enter second array elements---->"); for (i = 0; i <= n; i++) { b[i] = int.Parse(Console.ReadLine()); } Console.WriteLine("_________________"); } publicvoid display() { Console.WriteLine("BEFORE swaPping two arrays"); Console.WriteLine("first array"); for (int i = 0; i < n; i++)
  • 16. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment { Console.WriteLine(a[i]); } Console.WriteLine("_________________"); Console.WriteLine("second arrray"); for(int i=0;i<n;i++) { Console.WriteLine(b[i]); } //swapping for(i=0;i<n;i++) { c[i]=a[i]; a[i]=b[i]; b[i]=c[i]; } Console.WriteLine("AFTER swap"); Console.WriteLine("first array"); for(i=0;i<n;i++) { Console.WriteLine(a[i]); } Console.WriteLine("second array"); for(i=0;i<n;i++) { Console.WriteLine(b[i]); } Console.WriteLine("_________________"); } } classsub_swapping { publicstaticvoid Main(string[] args) { int ch; do
  • 17. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment { swaping sw = newswaping(); sw.input(); sw.display(); Console.WriteLine("do u wanto conntinue(1) or (0)"); ch = int.Parse(Console.ReadLine()); } while (ch == 1); } } } Output: enter of no of elements 4 enter first array----> 5 23 1 67 _______________ enter second array elements----> 2 3 42 12 12 _________________
  • 18. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment BEFORE swapping two arrays first array 5 23 1 67 _________________ secondarrray 2 3 42 12 AFTER swap first array 2 3 42 12 second array 5 23 1 67
  • 19. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment _________________ LABLIST - 2 : EX.NO-6 Ascending and desceding order of number SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication19 { class ascdes { int n; int[] a = new int[10]; public void input() { Console.WriteLine("Enter the Number"); n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { Console.Write("Number[{0}]=", i); a[i] = int.Parse(Console.ReadLine()); } } public void asc() { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] < a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } }
  • 20. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.WriteLine("Ascending Order of Given Number:"); for (int i = 0; i < n; i++) { Console.WriteLine(a[i]); } } public void des() { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i] > a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } } Console.WriteLine("Descending Order of Given Number:"); for (int i = 0; i < n; i++) { Console.WriteLine(a[i]); } } } class Program { static void Main(string[] args) { int ch; do { ascdes a = new ascdes(); Console.WriteLine("Ascending And Descending Order"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); a.input(); a.asc(); a.des(); Console.WriteLine("Do You want to perform again Press(1/0)"); ch = int.Parse(Console.ReadLine()); } while (ch == 1); Console.ReadLine();
  • 21. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment } } } OUTPUT: Ascending And Descending Order ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter the Number 6 Number[0]=2 Number[1]=4 Number[2]=6 Number[3]=2 Number[4]=8 Number[5]=78 Ascending Order of Given Number: 2 2 4 6 8 78 Descending Order of Given Number: 78 8 6 4 2
  • 22. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment 2 LAB LIST - 2 : EX.NO-7 SUM OF DIAGONAL IN A MATRIX SOURCE CODE: using System; using System.Collections.Generic; using System.Text; class mat { int i, j, m, n; int[,] a = new int[20, 20]; public void get() { Console.WriteLine("Enter Row Value"); m = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Column Value"); n = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Elements one by one"); for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { a[i, j] = int.Parse(Console.ReadLine()); } } Console.WriteLine("Given Matrix"); for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { Console.Write("t{0}", a[i, j]); } Console.WriteLine(); } } public void diag() {
  • 23. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment int d; d = 0; if (m == n) { for (i = 1; i <= m; i++) { for (j = 1; j <= n; j++) { if (i == j) { d = d + a[i, j]; } } } Console.WriteLine("Diagonal Sum= {0}", d); } else { Console.WriteLine("Can't Perform Diagonal Sum"); } } class matsum { static void Main(string[] args) { mat ma = new mat(); ma.get(); ma.diag(); Console.Read(); } } }
  • 24. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment OUTPUT:
  • 25. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment LABLIST:2 EX.NO-8 LARGEST AND SMALLEST VALUES OF MATRIX SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication16 { classrever { int[,] mat= newint[10,10]; int i,j,row,col,small,big; publicvoid input() { Console.WriteLine("Enter the Number of Rows and Columns"); row = int.Parse(Console.ReadLine()); col = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the Element of the Matrix"); for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { mat[i, j] = int.Parse(Console.ReadLine()); } } Console.WriteLine("Elements in a Matrix"); for (i = 0; i < row; i++) { for (j = 0; j < col; j++) {
  • 26. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.Write(mat[i,j]+"t"); } Console.WriteLine(); } } publicvoid min() { big=mat[0,0]; small=mat[0,0]; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { if(mat[i,j]<small) small=mat[i,j]; if(mat[i,j]>big) big=mat[i,j]; } } Console.WriteLine("Smallest Element in a Matrix={0}",small); Console.WriteLine("Largest Element in a Matrix={0}",big); } } classProgram { staticvoid Main(string[] args) { int ch; do { rever r = newrever(); Console.WriteLine("Find Smallest And Largest value of a MAtrix"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); r.input(); r.min(); Console.WriteLine("Do You want to perform again Press(1/0)"); ch = int.Parse(Console.ReadLine()); } while (ch == 1);
  • 27. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Console.ReadLine(); } } } Output: Find Smallest And Largest value of a MAtrix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter the Number of Rows and Columns 3 3 Enter the Element of the Matrix 2 2 2 234 12 6 7 1 78 Elements in a Matrix 2 2 2 234 12 6 7 1 78
  • 28. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Smallest Element in a Matrix=1 Largest Element in a Matrix=234 Lab List - 2 : EX.NO-9 NPR and NCR(Permitation and combination) SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication7 { classncr { publicvoid ncr_met() { int n, r, per, fact, fact1, fact2; Console.WriteLine("calculate NCR values"); Console.WriteLine("Enter the Value of 'n' and 'r' to find the Permutation :"); n = Convert.ToInt32(Console.ReadLine()); r = Convert.ToInt32(Console.ReadLine()); fact = n; for (int i = n - 1; i >= 1; i--) { fact = fact * i; } fact2 = r; for (int i = r - 1; i >= 1; i--) { fact2 = fact2 * i; } int number; number = n - r; fact1 = number; for (int i = number - 1; i >= 1; i--) { fact1 = fact1 * i; }
  • 29. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment fact1 = fact2 * fact1; per = fact / fact1; Console.WriteLine("Combination : {0}", per); } publicvoid pnr_method() { int n, r, per, fact, fact1; Console.WriteLine("Calculate NPR values"); Console.WriteLine("Enter the Value of 'n' and 'r' to find the Permutation :"); n = Convert.ToInt32(Console.ReadLine()); r = Convert.ToInt32(Console.ReadLine()); fact = n; for (int i = n - 1; i >= 1; i--) { fact = fact * i; } int number; number = n - r; fact1 = number; for (int i = number - 1; i >= 1; i--) { fact1 = fact1 * i; } per = fact / fact1; Console.WriteLine("Permutation : {0}", per); } } classsu_method { publicstaticvoid Main(string[] args) { int ch; do { ncr np = newncr(); np.ncr_met(); np.pnr_method(); Console.WriteLine("do u want to continue(1) or (0)"); ch = Int32.Parse(Console.ReadLine());
  • 30. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment } while (ch == 1); Console.ReadLine(); } } } OUPUT: calculate NCR values Enter the Value of 'n' and 'r' to find the Permutation : 4 5 Combination : 0 Calculate NPR values Enter the Value of 'n' and 'r' to find the Permutation : 12 23 Permutation : -43545600 do u want to continue(1) or (0) 1 calculate NCR values Enter the Value of 'n' and 'r' to find the Permutation : 5 4 Combination : 5
  • 31. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Calculate NPR values Enter the Value of 'n' and 'r' to find the Permutation : 2 1 Permutation : 2 do u want to continue(1) or (0)
  • 32. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment Lab List - 2 : EX.NO-10 LCM and GCD OF GIVEN NUMBER SOURCE CODE: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication14 { classpro_lcm { int a,b,n1,n2,swap,lcm,gcd; publicvoid input() { Console.WriteLine("Enter the Number"); a = Int32.Parse(Console.ReadLine()); b = Int32.Parse(Console.ReadLine()); } publicvoid calc() { n1 = a; n2 = b; while (n2 != 0) { swap= n2; n2 = n1 % n2; n1 = swap; } gcd=n1; lcm = (a * b) / gcd; Console.WriteLine("lcm of {0} and {1}is {2}", a, b, lcm); Console.WriteLine("gcd of {0} and {1} is {2}", a, b, gcd); } }
  • 33. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment classpro { publicstaticvoid Main(string[] args) { int ch; do { pro_lcm pl = newpro_lcm(); pl.input(); pl.calc(); Console.WriteLine("do u want to continue(1) or(0)"); ch = Int32.Parse(Console.ReadLine()); } while (ch == 1); } } } OUTPUT: Enter the Number 45 50 lcm of 45 and 50is 450 gcd of 45 and 50 is 5 do u want to continue(1) or(0)
  • 34. SUB NAME: .NET PROGRAMMING Dr.M.KarthikaITDepartment