0% found this document useful (0 votes)
11 views18 pages

Sample Lab Problems

The document outlines a series of programming exercises for a lab course, focusing on various string and array manipulations, mathematical computations, and data structures in C. Each exercise includes a description of the task, sample inputs, and expected outputs. The exercises cover topics such as counting characters, validating parentheses, performing operations on matrices, and implementing algorithms like sorting and searching.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views18 pages

Sample Lab Problems

The document outlines a series of programming exercises for a lab course, focusing on various string and array manipulations, mathematical computations, and data structures in C. Each exercise includes a description of the task, sample inputs, and expected outputs. The exercises cover topics such as counting characters, validating parentheses, performing operations on matrices, and implementing algorithms like sorting and searching.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

FY-PSAP LAB sample program : similar difficulty level any program will be asked

E01
Given a string, S , consisting of alphabets and digits, find the number of
alphabets and digits in the given string.
Test Case 1:
Sample Input: a11472o5t6

Number of digits: 7

Number of alphabets:3

E02
Given a string s containing just the characters like:
'(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if number of opening and closing brackets is same
(irrespective of the sequence of opening and closing brackets)
Test Case 1:
Sample Input: ( )
Sample Output: Valid

Test Case 2:
Sample Input: ( )[ ]{ }
Sample Output: Valid

Test Case 3:
Sample Input: ( [ { }
Sample Output: Invalid
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E03
Given a string s, perform following operations on a string using function
(Without pointer):
1. Find a length of a string.
2. Print string in reverse order.
3. Copy string s into s1 and print it.
4. Accept another string, say s2. Concatenate s and s2 and print
concatenated string.

E04
Given a string s, perform following operations on a string using function
(With pointer):
1. Find a length of a string.
2. Print string in reverse order.
3. Copy string s into s1 and print it.

E05
Given a string s, return true if it a Palindrome or false otherwise.
Test Cases:
Case 1:
Input: MADAM
Output: true
Case 2:
Input: CAR
Output: false
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E06
Accept limit of array from user. As per the limit, read integer elements in
array. Then print :
1. Minimum, Maximum number from array.
2. Search for a particular number from array.

E07
You are given a string s and an integer array index of the same length. The
string s will be shuffled such that the character at the ith position moves
to indices[i] in the shuffled string.
Return the shuffled string.

Test Cases:
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output: "leetcode"
Explanation: As shown, "codeleet" becomes "leetcode" after shuffling.

Input: s = "abc", indices = [0,1,2]


Output: "abc"
Explanation: After shuffling, each character remains in its position.
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E08
1. Write a Program to print the output like:
A
A B
A B C
A B C D
A B C D E
A B C D
A B C
A B
A
2. Write a program to print factorial of 1 to 10 numbers.

E09
1. Write a Program to print the output like:

1
12
123
12345
E D C B A
E D C B
E D C
E D
E
FY-PSAP LAB sample program : similar difficulty level any program will be asked

2. Write a program to print prime numbers between two numbers given


by user.

E10
Write a C program to find the frequency of each character in a string.
Test Cases: String: This book is very good
Frequency of T:1
Frequency of h:0
Frequency of o:4 and so on for every distinct character.

E11
Write a C program to print Fibonacci series up to n
terms.

Test Cases: No. of terms 10


Output: 0,1,1,2,3,5,8,13,21,34
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E12
Write a C program to count the number of Vowels and

Consonants.

Test Cases: String: C is a programming language.

Vowels: 9

Consonants: 14

E13
Write a program to convert decimal to binary
number.
Test Cases:
Input : 5
Output: 101
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E14
Write a C program to reverse an array using
pointers.
E15
Write a function to print all perfect numbers in a
given interval in C programming.

Test Cases:1) Enter lower limit to print perfect numbers:1


Enter Upper limit to print perfect numbers:10000
All perfect numbers between 1 to 10000 are:
6,28,496,8128
2) Enter lower limit to print perfect numbers: 23
Enter upper limit to print perfect numbers: 450
All perfect numbers between 23 to 450 are:
28
3) Enter lower limit to print perfect numbers: 15
Enter upper limit to print perfect numbers: 70
All perfect numbers between 15 to 70 are: 28
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E16
Write a C Program to read and print name and
other details like mobile number, marks of 5
subjects of n number of students using
Structure. Print data of top 5 students ( top 5
should be calculated based on the entered
marks)

E18
Write a C program to store student data(roll no, name,
marks of 5 subjects) in structure. Then calculate the
grade of a student using a logical operator.

(76-99 Distinction
60-75 First Class
50-59 Second Class
40-49 Pass Class
Below 40 Fail)
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E19

Write a c program for swapping of two arrays using


call by value and call by reference separately
function.
E20
Write a C program to count the number of digits in
an integer. Then print addition of all digits in the
given number.

Test Cases:
1) input: 671041

output:
Number of digits:6
Addition of digits:19
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E21

1. Find the sum of two one-dimensional arrays


using functions. Array should be passed as a
function argument and in function should perform
addition of passed arrays.

E22

Perform following operations on 2D Matrix:


2. Accept number of rows and columns of two
matrices and read elements of both matrices.
3. Print Transpose of both matrices.
4. Print Diagonal elements of both matrices.
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E23
Create a structure named Date having day, month
and year as its elements.
Store the current date in the structure. Now add 45
days to the current date and display the final date.

Test Cases:
Input : dd mm yy (e.g 6 /3/23)
Output: dd/mm/yy (20/4/23)

E24
Write a structure to store the roll no., name, age
(between 11 to 14) and address of students (5
students). Store the information of the students.

1 - Write a function to print the names of all the


students having age 14.
2 - Write a function to print the names of all the
students having even roll no.
3 - Write a function to display the details of the
FY-PSAP LAB sample program : similar difficulty level any program will be asked

student whose roll no is given (i.e. roll no. entered


by the user).

E25
Write a structure to store the names, salary, and hours
of work per day of 10 employees in a company. Write a
program to increase the salary depending on the number
of hours of work per day as follows and then print the
name of all the employees along with their final
salaries. Assume:

Hours of work per day 8 10 >=12


Increase in salary ₹4000 ₹8000 ₹12000
Test Cases: Input
A 40000 8
B 10000 10
C 60000 14
Output:
A 44000 8
B 18000 10
C 72000 12
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E26
1. Write a Program to print the output like:

E27
1. Write a Program to print the output like:

E28
1. Write a Program to print the output like:
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E29
Perform following operations on 2D Matrix:
5. Accept number of rows and columns of two
matrices and read elements of both matrices.
6. Print Transpose of both matrices.
7. Print Addition of two matrices.
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E30
Accept number of rows and columns and read elements of matrix.
1. Print matrix in row major format.
2. Print matrix in column major format.
Test Case 1:
Number of rows:2
Number of columns: 3
Matrix Elements: 1 2 3 4 5 6
Row Major:
1 2 3
4 5 6
Column Major
1 3 5
2 4 6
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E31

E32
Write a c program to Delete all occurrences of Character from the
String.
Test case: Computer_engineering
Enter character to delete: e
Output: Computr_nginring
E33
Write a c program to insert a sub-string in to given main string.

Enter First String: Life is beautiful


Enter Second String: very
Enter the position to insert second string in first: 9
Output: Life is very beautiful

E34
1. Write a C program to print a given string in upper case using
C
2. Write a C program to Reverse a string using pointers
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E35
1. Write a C program to evaluate a^b using function.

2. Write a C program to find out the maximum number in an


array using function.
E36
Write a C program to find HCF and LCM of two numbers given by
user.
E37
Write a C program to accept two matrices and check if they are
equal or not. Order of both matrices must be accepted from user at
run time.

E38
1. Write a C program to insert a given number in the array at
given position.
2. Write a C program to remove a number in the array from a
given position.

E39
Write a c program for swapping of two arrays using function and
check if both arrays are equal or not. Limits and numbers of both
arrays must be accepted from user at run time.
FY-PSAP LAB sample program : similar difficulty level any program will be asked

E40
Write a C program for swapping of two string
E41
Write a C program for sorting list of elements using bubble sort.
E42
Write a C program for sorting list of elements using selection sort
E43
Write a C program to search element in given list using linear
search . also find largest element in given array.
E44
Write a C program to find duplicate element in an array.

E45
Write a C program to insert element in an array on given specific
position.

You might also like