Lab Session 5
Lab Session 5
Lab Session – 5
Date:
Pre-Lab|5:
1. Given a string s1, write a c program to find the length of the string with and without using string handling
function. Use switch to select an option to the user.
Program code:
Programming Using C Lab (24IT101) Register Number:
2. Given two strings string1, string2. Write a program to compare the given two strings with and without
using string handling functions.
Program code:
Programming Using C Lab (24IT101) Register Number:
Computer Programming Lab Register Number:
In-lab:5
1. A matrix can only be added to another matrix if the two matrices have the same dimensions. To add two
matrices, just add the corresponding entries, and place this sum in the corresponding position in the matrix
which results.
Input elements in 3x3 matrix1: 1 2 3
456
789
Input elements in 3x3 matrix2: 9 8 7
654
321
Sum of both matrix = 10 10 10
10 10 10
10 10 10
Program code:
Programming Using C Lab (24IT101) Register Number:
Computer Programming Lab Register Number:
Programming Using C Lab (24IT101) Register Number:
2. Matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix
multiplication, the number of columns in the first matrix must be equal to the number of rows in the
second matrix. The resulting matrix, known as the matrix product, has the number of rows of the first
and the number of columns of the second matrix. The product of matrices A and B is denoted as AB.
Programming Using C Lab (24IT101) Register Number:
Programming Using C Lab (24IT101) Register Number:
Programming Using C Lab (24IT101) Register Number:
Post–Lab:5
1. Input two strings str1 in lowercase, str2 in uppercase. Print the lower case string str1 in uppercase and the
uppercase string str2 in lowercase.
Sample Input:
Enter String1: hello
Enter String2: WELCOME
Sample Output:
String1: HELLO
String2: welcome
Program code:
Programming Using C Lab (24IT101) Register Number:
2. Write a C program to find and print the transpose of a given matrix. The program should:
1. Accept the number of rows (m) and columns (n) from the user.
2. Take input for the m × n matrix.
3. Compute and display the transpose of the matrix, where the rows become columns and vice versa.
Program code:
Programming Using C Lab (24IT101) Register Number:
Programming Using C Lab (24IT101) Register Number: