0% found this document useful (0 votes)
15 views

10

The document describes several C# programs that demonstrate different programming concepts: 1) A program that adds two matrices using multi-dimensional arrays. It declares arrays, reads matrix values, adds the matrices and stores the result. 2) A program using strings that clones a string, compares strings, concatenates strings, and converts strings to lower/upper case. 3) A program using classes and objects that defines an Employee class with a display method, creates Employee objects, and gets/displays employee details. 4) Additional programs demonstrate using interfaces by defining and implementing an interface, and overloading binary operators in a class.

Uploaded by

20UCA519 Eswar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

10

The document describes several C# programs that demonstrate different programming concepts: 1) A program that adds two matrices using multi-dimensional arrays. It declares arrays, reads matrix values, adds the matrices and stores the result. 2) A program using strings that clones a string, compares strings, concatenates strings, and converts strings to lower/upper case. 3) A program using classes and objects that defines an Employee class with a display method, creates Employee objects, and gets/displays employee details. 4) Additional programs demonstrate using interfaces by defining and implementing an interface, and overloading binary operators in a class.

Uploaded by

20UCA519 Eswar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

10.

ADDITION OF MATRICES USING

MULTIDIMENSIONAL ARRAY

AIM:

To write a C# program to Add Two matrices using Multi dimensional array.

ALGORITHM:

STEP1: Start the program.

STEP 2: Declare three multi-dimensional array arr1,arr2,arr3 and read the respective rows and column

values in variables r and c.

STEP3: Read the values matrices arr1 and arr2 using for loop.

STEP4: Print the array elements of first matrix and second matrix in matrix format.

STEP5: Add arr1 and arr2 and store the result in arr3. This is done by dual for loops with looping variables i, j.
(arr3[i,j]=arr1[i,j]+arr2[i,j])

STEP6: Print the elements of the array arr3 in the

matrix format.

STEP7: Stop the program.

11.PROGRAM USING STRINGS

Aim:

To write a c# program using strings.

Algorithm:

1.Start the program.

2. Declare s1 , s2 as string

3. Read the values for s1 and s2.

4. Using clone() function on string s1 to clone the string object , and copy it to s.

5.Print string s1 and s2 are equal if the string.compare() function returns 0. Else print, string s1 and
s2 are not equal.

6.Concatenate two strings s1 and s2 using string function concat() and print.

7.Print every character of string s1 to lower case using string function ToLower().
8. Print every character of string s2 to upper case using string method ToUpper().

9.Stop the program.

12.PROGRAM USING CLASSES

AND OBJECTS

Aim:

To write a c# program using classes and objects.

Algorithm:

1.Start the program.

2.Define a class , Employee with member function display() to print the employee id , name and
salary.

3.Create object for class , Employee.

4.Get the input for id , name and salary.

5.Invoke display() method using object to display the employee details.

6.Stop the program.

EX NO:15 PROGRAM USING INTERFACE

AIM:

To write a program using interface.

ALGORITHM:

Step1:Start the program.

Step2: Declare an interface using name inter1.

Step3: In interface, define display method.

Step4:Define class using name testclass and inherit the interface.

Step5:Define the display method of the interface in testClass, Get input for a,b and print the result.

Step7: In main method, create object for the class testclass.


Step8:Call the display() using object.

Step9:Stop the program.

EXNO:16 BINARY OPERATOR OVERLOADING

AIM:

To write a program for binary operator overloading.

ALGORITHM:

Step1:start the program.

Step2:Define class complex, inside the class initialize x and y variable using constructor.

Step3:Define showxy()method to display x and y values.

Step4:Define complex operator overloaded method. Create object temp for class, complex. Add x and y and store it
onto temp.

Step5: Inside the main function, create three objects c1,c2,c3 for class complex.

Step 6: Arithmetic operation on objects (c3 = c1 + c2) invokes the operator overloaded method.

Step7: Show the results using showxy() method.

Step8:Stop the program.

You might also like