PSC_List of Experiments
PSC_List of Experiments
(CS1030)
LAB MANUAL
(2022-23)
Faculty of Engineering
CONTENTS
1. Instructions to Students
2. Lab Evaluation Scheme
3. List of Experiments
4. References
5. Additional Exercises
INSTRUCTIONS TO STUDENTS
1. Students should be regular and come prepared for the lab practice.
2. In each lab session, at least 4 programs should be executed and shown to the lab instructor.
Remaining programs should be executed and shown as home assignments.
3. In case a student misses a class, it is his/her responsibility to complete that missed
experiment(s).
4. Students should bring and maintain an observation book exclusively for the lab.
5. Once the experiment(s) is/are executed, they should show the program and results to the
instructors and copy the same in their observation book.
6. Students are also required to draw the corresponding flowcharts in the observation book during
the lab hours itself which will be evaluated later. Drawing of flowcharts are optional for the
programs from week 6. Prescribed textbooks and class notes can be kept ready for reference
if required.
7. Students are supposed to implement the given experiment individually.
8. While conducting the experiments students should see that their programs would meet the
following criteria:
a) Programs should be interactive with appropriate prompt messages, error messages if any,
and descriptive messages for outputs.
b) Programs should perform input validation (Data type, range error, etc.) and give
appropriate error messages and suggest corrective actions.
c) Comments should be used to give the statement of the problem and every function should
indicate the purpose of the function, inputs, and outputs.
d) Statements within the program should be properly indented.
e) Use meaningful names for variables and functions. Do not use any random names.
f) Make use of Constants and type definitions wherever needed.
9. Questions for lab tests and exams need not necessarily be limited to the questions in the manual
but could involve some variations and/or combinations of the questions.
10. Practice of additional exercises would be considered as formative assessment and may not be
written in lab records.
Home
Personal Official
Refer the directory structure shown in Fig. 1. Accomplish the following tasks, in sequence.
a. Create the directory structure as in Fig. 1 in your home directory.
b. Rename each file in Personal with the prefix P. i.e., the file Accounts in Personal
directory should be renamed as Paccounts.
c. Move the file named Paddress to a newly created directory in Home from its current
location.
d. Create a directory Backup under Home directory and move all the contents of
Personal into Backup.
e. Remove all the contents of Personal directory.
f. Now rename the Backup directory as Personal.
1. Write a program to take N as input and print the odd numbers in descending order.
2. Write a program to print the Fibonacci number.
Hint: (Fibonacci series is 0, 1, 1, 2, 3, 5, 8,)
3. Write a program to find whether the given number is prime or not.
4. Write a program to convert the decimal number into binary to decimal.
Ex: 1101 = 1*2 3 + 1 * 2 2 + 0 * 2 1+ 1* 2 0 =13
5. Write a program to reverse a given number
Ex: 1234 reverse=4*10 3 +3 * 10 2 + 2 * 10 1 + 1 * 10 0 =4321
6. Write a program to find the sum of n terms of the sin series sin(x) = x - x3 + x5 – x7
7. Write a program to check whether a given integer no. is palindrome or not.
8. Write a program to check whether the given number is Armstrong or not. An Armstrong
number of three digits is an integer such that the sum of the cubes of its digits is equal to
the number itself. For example, 371 is an Armstrong number since 33 + 73 + 13 = 371.
Lab 7. Control Structures: Nested Loops
1. Write a program to print different patterns using nested loops.
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5 5
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
1
2 4
3 5 7
6 8 10 12
9 11 13 15 17
5. Write a program to generate the multiplication table for n numbers up to k terms (nested
loops).
Hint: 1 2 3 4 5 …. K 2
4 6 8 10 … 2*k
……………….
………………..
n ………………. n*K
6. Write a program to print the Fibonacci numbers that fall in the given range.
7. Write a program to print that Nth the prime number.
8. Write a program to print that Nth the Armstrong number.
58 24 13 15 63 9 8 81 1 78
After splitting:
58 24 13 15 63
9 8 81 1 78
1. Write a program to change all lower-case letters into upper case in a sentence.
2. Write a program to find the last occurrence of a particular character.
3. Write a program to concatenate/length/copy two strings using the library function.
4. Write a program to count the number of words in a sentence.
5. Write a program to reverse a string.
6. Write a program to find the string length of a string without using the predefined function.
7. Write a program to find the substring of a given string.
8. Write a program to check if the given string is a palindrome or not.
1. Write a program to define a structure personal that would contain the person’s name, date
of joining, and salary. Using this structure write a program to read this information for
one person from the keyboard and print the same on the screen.
2. Write a program to create an array of student structures to store the roll no., name, and
marks in 3 subjects. Input the details of N students into the array and display roll no.,
name, and total marks of each student in decreasing order of total marks.
3. Write a program to create an array of employee structures to store emp-no, name, basic
salary, and HRA. Input the details of N employees and display emp-no, name, basic, HRA,
and net salary. Display the details of all employees whose net salary is more than the
average net salary of all employees.
4. Write a program to 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.
1. E. Balagurusamy, “Programming in ANSI C”, 7th Edition, McGraw Hill Publication, 2016.
2. Y. P. Kanetkar, “Let us C”, 12th Edition, BPB Publication, 2014.
3. B. W. Kernighan, D. M. Ritchie, “The C Programing Language”, 2nd Edition, Prentice
Hall of India, 2014.
4. Gottfried, “Schaum's Outline Series: Programming with C”, 3rd Edition, McGraw Hill
Publication, 2012.
ADDITIONAL EXERCISES
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
New Matrix:
1 2 3 6
1 2 3 6
1 2 3 6
3 6 9 18
26. WAP to print all combinations of a given word. (Eg: Rose => oser, osre…. Etc.)
27. Write an n digit number in words. (236=two three six)
28. Find the volume of a cylinder and a cube.
29. Find the LCM of two numbers.
30. Find all the primes in the multiplication tables ranging from 2 to 5 and store them in
the array without having duplicates.
31. Check all the rows, columns, principal diagonal, and secondary diagonal for
palindromes in an integer matrix of any order.
32. WAP to find the digital roots of numbers for multiplication tables ranging from 2 to
5 and store those forty resultant numbers in a matrix of order 4X10. (Digital root of
number is a single digit derived from adding all the individual digits of the number
repeatedly. (Eg: digital root of 2456= 2+4+5+6=17, again 1+7=8---> digital root)
33. Generate
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
34. Write a program to read a line, encode the line and display the original and encoded
form.
The encode should be:
a b c d ….. z
z y x w …. a
35. Write a program to find the time of the day when
a Hour and Minute hand are exactly opposite to each other.
b Hour and Minute hand are overlapping each other.