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

Lab Session 5

This document outlines the lab session activities for a Programming Using C Lab course, including tasks such as finding string length, comparing strings, matrix addition and multiplication, string concatenation, and reversing strings. It also includes post-lab exercises for converting string cases and finding the transpose of a matrix. Each task is accompanied by sample input and output, as well as program code requirements.

Uploaded by

sugunasri2736
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lab Session 5

This document outlines the lab session activities for a Programming Using C Lab course, including tasks such as finding string length, comparing strings, matrix addition and multiplication, string concatenation, and reversing strings. It also includes post-lab exercises for converting string cases and finding the transpose of a matrix. Each task is accompanied by sample input and output, as well as program code requirements.

Uploaded by

sugunasri2736
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Programming Using C Lab (24IT101) Register Number:

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:

3. Concatenate two strings without using built-in functions


Note: User would be asked to enter two strings and then the program would concatenate them. For
concatenation we have not used the standard library function strcat(), instead we have written a logic to append
the second string at the end of first string.
Test Data and Output:
Str1: Good Str2: Morning Output: Good Morning
Programming Using C Lab (24IT101) Register Number:

4. Reverse a string using built-in and without built-in string functions


Using built-in function: The function is used for reversing a string. The reversed string will be stored in the
same string.
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:

Evaluator Signature Marks Secured: Out of

You might also like