Sample Lab Problems
Sample Lab Problems
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.
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
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.
E12
Write a C program to count the number of Vowels and
Consonants.
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.
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
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
E22
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.
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:
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.
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.
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.