School of Computer Engineering
KIIT deemed to be University
Laboratory Lesson Plan – Autumn 2026 (1 st Semester)
Discipline: Computer Science and Engineering
Course name and Code: PROGRAMMING LABORATORY (CS13001)
(L-T-P-Cr: 0-2-4-4)
Instructor Name: Dr. Amiya Ranjan Panda
Instructor Chamber: Campus 25, C Block, Room No-C201
Sr # Details Week#
Fundamentals of computer programming, and basic Linux
1 1
commands.
2 Practice and write programs on simple input and output operations. 2
3 Practice and write programs on Operators and Expressions. 2
Practice and write programs on branching statements (all conditional
4 3
statements ).
Practice and write programs on looping (control) statements. Number
5 4, 5
system(as required for the program )
6 Practice and write programs on Arrays. (1-D and 2-D) 6,7
7 Mid Sem Exam 8
Practice and write programs on Functions, Storage class
8 9, 10
(Static,External,Auto,Register)
9 Practice and write programs on Character Array 11
10 Practice and write programs on Pointers,Dynamic Memory Allocation. 12, 13
11 Practice and write programs on Structures and Unions 14, 15
12 Practice simple programs on file handling 16
13 Sessional Exam
Technical Assistants Names:
Course Contents: Week-wise lesson plan
List of Experiments (Day wise):
Introduction To Programming, Linux Commands
Week1- Day 1, Day2
Fundamentals of computer programming
Flow chart, algorithm
Linux commands
man
ls
pwd
cd
mkdir
cp
mv
rm
rmdir
whereis
Hello World program
Operators & Expressions, Simple Input & Output Statements
Week2 - Day 3, Day4
Day 03: Lab Assignments
Q# Experiment Details Input Output
WAP to perform the
addition of two integers
Enter 1st number:12
1. and display the result. Sum is 25.
Enter 2nd number:13
Input must be given by
user.
WAP to find Fahrenheit
Enter the temperature The Fahrenheit
2. for a given centigrade
in Centigrade: 30 temperature is: 86
temperature.
WAP to calculate area of
Enter the radius of the
3. a circle while taking The area is: 380.12
circle: 11
radius as user input.
WAP to calculate area of Enter the height of the
a triangle who’s base triangle: 12 The area of the
4
and height are user Enter the base of the triangle is: 60.
input. triangle: 10
Write a C program to Before Swapping
perform swapping of two Enter num1: 10 num1=10, num2=20
5
integers using a third Enter num2: 20 After Swapping
variable. num1=20, num2=10
Day 03 : Home Assignments
Q# Experiment Details Input Output
Write a C program to Enter num1: 10 Before Swapping
perform swapping of two Enter num2: 20 num1=10
integers without using a num2=20
1. third variable. After Swapping
num1=20
num2=10
WAP to find the average Enter the number of 1st The average is: 172.
mark of 5 subjects of a subject: 160 The percentage is: 86%
student and find the Enter the number of 2nd
percentage. Assume full subject: 170
mark of each subject is Enter the number of 3rd
2.
200. All the input must subject: 165
be given by user. Enter the number of 4th
subject: 180
Enter the number of 5th
subject: 185
WAP to convert given Enter the amount:550 550 paisa = 5 Rupee and
paisa into its equivalent paisa. 50 paisa
3
rupee and paisa as per
the following format.
Day 04: Lab Assignments
Q# Experiment Details Input Output
WAP to convert given second
7560 second = 2 Hour,
into its equivalent hour, Enter the time:7560
1. 27 Minute and 40
minute and second as per the second.
Second
following format.
WAP to convert a distance in
meter entered through
Enter the distance: 2430 meter = 2 Km
2. keyboard into its equivalent
2430 meter. and 430 meters.
kilometer and meter as per the
following format.
WAP to find the sum of 1st
Enter the number:
3. and last of a six-digit number. Sum of digits is: 11.
234459
Number must be a user input.
WAP to find the sum of all
Enter the number:
4. digits of a three-digit number. Sum of digits is: 12.
354
Number must be a user input.
Set 1:
Enter the buying
The buying price, the marker price: 80
price and discount are entered Enter the marker
through keyboard. Sometimes price: 100. Set 1:
seller gets profit or sometimes Enter the discount: Seller made a loss of
loss depending upon the 25% 6.25%.
5.
discount. WAP to determine Set 2:
whether the seller has made Enter the buying Set 2:
profit or incurred loss. Also price: 80 Seller made a profit of
determine how much profit he Enter the marker 12.50%.
made or loss he incurred. price: 100.
Enter the discount:
10%
Day 04: Home Assignments (Practice Problems)
Q# Experiment Details Input Output
WAP to reverse a three-digit
Sum of digits is:
1. number. Number must be a Enter the number: 376.
673.
user input.
WAP to swap the contents of Before Swapping
two variables by using a Enter num1: 10 num1=10,
single statement for swap. Enter num2: 20 num2=20
2.
After Swapping
num1=20,
num2=10
WAP to add two times in hour, Enter two times: Output time is
minute & second format 11:45:34 and 09:28:41 21:14:15
entered through the keyboard [Input must be taken in
3.
in the format hh:mm:ss such a way so that sum
should not exceed 24
hours]
Day 04: Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 67, Exercise 3.9
2. Page No: 67, Exercise 3.11
3. Page No: 67, Exercise 3.12
4. Page No: 97, Exercise 4.4
Branching Statements: if…else, switch…case
Week 3 - Day 5,6
Lab Assignments
Q# Experiment Details Input Output
1 WAP to find the largest Enter two numbers: The largest number is
between two numbers. 80 990
990
2 WAP to read an alphabet Set 1 Set 1
from the user and convert Enter an alphabet: k The upper case of the
it into uppercase if the Set 2 entered letter is ‘K’
entered alphabet is Enter an alphabet: M Set 2
in lowercase, otherwise You have entered ‘M’
display an appropriate which is already in
message. upper case
3 WAP to read a character Set 1: Set 1:
from the user and test Enter an alphabet: B The entered character
whether it is a vowel or B is a consonant
consonant or not an Set 2:
alphabet. Enter an alphabet: % Set 2:
The entered
character % is not an
alphabet
4 WAP to determine whether Set 1: Set 1:
a year entered through the Enter the year:2005 2005 is not a leap year.
keyboard is a leap year or
not. Set 2: Set 2:
Enter the year:1996 1996 is a leap year.
5 WAP to find the roots of a Set 1 Set1
quadratic equation Input values for a, b The roots are real and
ax2+bx+c=0 using if-else and c=>1 2 1 equal
statement. Roots are -1 both.
Set 2 Set2
Input values for a, b The Roots are real &
and c=>1 8 3 unequal.
Roots are -0.39 and -
7.61
Set 3 Set 3
Input values for a, b The Roots are
and c=>3 5 7 imaginary
Root1=-0.17+i1.28
Root2=-0.17-i1.28
6 WAP to display the grade Set-1 Set-1
system of KIIT University Enter total mark
based on total marks secured by a student: Secured grade is C
secured by a student in a 55
semester. Assume marks Secured grade is C Set-2
are integer values. Use Secured grade is O
multiple if-else statement. Set-2
The grade is calculated is Enter total mark
as follows: secured by a student:
Marks Grade 95
90 to 100 O Secured grade is O
80 to 89 E
70 to 79 A
60 to 69 B
50 to 59 C
40 to 49 D
< 40 F
7 WAP to input any two Enter 2 numbers: The Sum is 109
integers, and provide a 9
menu to the user to select 100
any of the options as Select the operation
add, subtract, multiply, from the menu
divide and display the (A for Add, S for
result accordingly Subtract, M for
Multiplication, D for
Division) :
A
8 Print weekday name Enter the week day: 3 This is Wednesday
program according to given
weekday number using
switch-case
weekday number (0-6) and
print weekday name
(Sunday, Monday,
Tuesday, Wednesday,
Thursday, Friday, and
Saturday)
9 WAP to display the grade Set-1 Set-1
system of KIIT University Enter total mark Secured grade is A
based on total marks secured by a student:
secured by a 77 Set-2
student in a semester. Use Secured grade is C Secured grade is O
else..if ladder statement.
Set-2
Enter total mark
secured by a student:
92
Secured grade is O
10 WAP to find the roots of a Input values for a, b Input values for a, b
quadratic equation and c=> and c=>1
ax2+bx+c=0 using switch- 1 2
case statement. 2 1
1
Set2
Set2 The Roots are real &
Input values for a, b unequal.
and c=>1 8 3 Roots are -0.39 and -
7.61
Set 2
Input values for a, b Set 3
and c=>3 5 7 The Roots are
imaginary
Root1=-0.17 + i1.28
Root2=-0.17 - i1.28
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
1 WAP to test whether a number Set 1 Set 1
entered through keyboard is ODD Enter a number: 19 is an ODD number
or EVEN. 19 Set 2
Set 2 100 is an EVEN
Enter a number: number
100
2 WAP to determine the eligibility for Input the marks The candidate is not
admission based on the following obtained in eligible for admission.
criteria: Physics :65
Input the marks
Eligibility Criteria: obtained in
Marks in Maths >=65 and Marks in Chemistry :51
Phy >=55 and Marks in Chem>=50 Input the marks
and obtained in
Total in all three subjects >=190 or Mathematics :72
Total in Maths and Physics >=140
3 WAP to check whether the triangle Set 1 n1=3, Set 1 Isosceles
is equilateral, isosceles or scalene n2=3, n3=4
(Triangle consists of three sides of Set 2 n1=4, Set 1 Equilateral
provided lengths n1, n2 and n3 n2=4, n3=4
units). Set 3 n1=4, n2 Set 3 Scalene
=5, n3=7
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 167, Exercise 6.2
Page No: 167, Exercise 6.3
2.
3. Page No: 168, Exercise 6.8
4. Page No: 169, Exercise 6.12
Looping: while, do…while and for
Week 4 & 5 - Day 7,8,9,10
Day 7
Lab Assignments
Q# Experiment Details Input Output
1 WAP to print even series 2 4 6 8 10 12 14 16 18
within 50. 20 22 24 26 28 30 32 34
36 38 40 42 44 46 48 50
2 WAP to print the natural Set 1 Set 1
numbers from 1 to n n=5 12345
(value of n is user input). Set 2 Set 2
n=7 1234567
3 WAP to print the natural Set 1 Set 1
numbers from n to n=5 54321
1(value of n is user input). Set 2 Set 2
n=7 7654321
4 WAP to take 10 different Enter 10 numbers: The sum is 529
numbers as input. Print 54 The average is
their sum and average. 32 52.900002
56
76
87
90
23
12
44
55
5 WAP to find out sum of Set 1 Set 1
digits of a number. n=234 The sum of digits of 234
is 9
Set 2 Set 2
n=1235 The sum of digits of
1235 is 11
6 WAP to find out reverse of Set 1 Set 1
a number. n=234 The reverse of 234 is 432
Set 2 Set 2
n=1235 The reverse of 1235 is
5321
Home Assignments
Q# Experiment Details Input Output
1 WAP to find out factors of a Set 1 Set 1
number. n=6 The factors are
1236
Set 2 Set 2
n=21 The factors are
1 3 7 21
2 WAP to test whether a number is Set 1 Set 1
Armstrong Number or not. n=153 The given number is
(A number is said to be Armstrong
Armstrong when the sum of Set2 Set 2
cubes of its digit is equal with n=121 The given number is not
the original number. Armstrong
Ex-153)
3 WAP to test whether a number is Set1 Set 1
Palindrome Number or not. n=234 The given number is not
(A number is said to be Palindrome
Palindrome when its reverse is Set 2 Set 2
equal with the original number. n=121 The given number is
Ex-121) Palindrome
Day 8
Lab Assignments
Q# Experiment Details Input Output
1. WAP to print Fibonacci series Set 1 Set 1
up to n terms. n=5 01123
Set 2 Set 2
n=10 0 1 1 2 3 5 8 13 21
34
2 WAP to test whether a number Set 1 Set 1
is Perfect Number or not.
n=7 The given number is
(A number is said to be Perfect not Perfect
when the sum of factors
excluding the number itself is Set 2
Set 2
equal to the original number.
The given number is
n=28 Perfect
Ex-6)
3 WAP to check whether a Set 1: Set 1:
number n is prime number or
not. Enter a number:17 You have entered
17. 17 is a prime
number
Set 2: Set 2:
Enter a number:25 You have entered
25. 25 is NOT a
prime number
4 The first few numbers of the Enter number of
Lucas sequence which is a Lucas numbers to be
variation on the Fibonacci generated: 7 1 3 47 1118 29
sequence are:
1 34 711 1829 …
WAP to generate the Lucas
sequence.
5 WAP to print GCD and LCM of Enter two numbers: GCD of 12 and 18 is
two numbers. 6
12
LCM of 12 and 18 is
18 36
6 WAP to find out factorial of a Set 1 Set 1
number.
n=5 Factorial is 120
Set 2 Set 2
n=4 Factorial is 24
7 WAP to test whether an Set 1 Set 1
inputted number is a strong
number or not. n=145 The given number is
Strong
(A number is said to be Strong if
sum of factorial of digits is Set 2
Set 2
equal to the original number)
The given number is
n=121 not Strong
8 WAP to display this series (3 in Enter the value of n: 0 1 1 2 4 7 13 24 44
a single loop).
9
Home Assignments
Q# Experiment Details Input Output
1. WAP to sum the following series Enter the 20
S=1+(1+2)+(1+2+3)+...+(1+2+3+...+n) value of n: 4
2. WAP to find out 1/n! Enter the The value of 1/6! is
value of n: 0.001389
3. WAP to find out xn/n! Enter the The value is 2.0
value of x and
n:
22
4. WAP to find out sum of series up to Enter the The sum of series is
n terms. range: 3.180134
(1+1/2+1/3………) 13
5. WAP to find out sum of series up to Set 1: Set 1:
n terms.
Enter the The value is 3.0
value of x and
n:
2 2
Set 2: Set 2:
Enter the The value is 3.666667
value of x and
n:
2 3
Day 9 & Day 10
Lab Assignments
1. WAP to find out sum of series up to n Enter the The sum of series is
terms value of n: 873612.0
1+22+33+……….+nn 7
2. WAP to find out sum of series up to n Enter the The sum of series is
terms value of n: 13.477573
7
3. WAP to print the following pattern for Enter Row 1 1 1 1
rows = 4 Number: 4 2222
1111 3333
2222 4444
3333
4444
4. WAP to print the following pattern Enter Row 1
1 Number: 5 12
12 123
123 1234
1234 12345
12345
5. WAP to print the following pattern Enter Row 1
1 Number: 5 22
22 333
333 4444
4444 55555
55555
6. WAP to print the following pattern Enter the 1 3 7 15 31
1 3 7 15 31……. value of n:
5
7. WAP to print the following pattern Enter the *
* value of n: **
** 5 ***
*** ****
**** *****
*****
Home Assignments
1. WAP to print the Enter the value of *
following pattern n: ***
* 5 *****
*** *******
***** *********
*******
*********
2. WAP to print the Enter the value of A
following pattern n: BA
A 5 CBA
BA DCBA
CBA EDCBA
DCBA
EDCBA
3. Write a C program to Enter the value of * * * * *
print a hollow square n: * *
pattern using a while 4 * *
loop. For row=4 *****
*****
* *
* *
*****
4. WAP to print the Enter the value of *********
following pattern n: *******
********* 5 *****
******* ***
***** *
***
*
5 WAP to print the Enter the value of 1
following pattern n: 21
1 5 123
21 4321
123 12345
4321
12345
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 208, Exercise 7.6
Page No: 209, Exercise 7.12
2.
Page No: 209, Exercise 7.13
3.
3. Page No: 210, Exercise 7.18
Array
Week 6 & 7
DAY 11
TOPIC: 1-D Arrays
Lab Assignments
Q# Experiment Details Input Output
1. WAP to create an array that Enter array size (N): 5 Array Contents are:
can store N integers and Enter number1: 45 45 35 38 31 49
display the contents of the Enter number2: 35
array Enter number3: 38
Enter number4: 31
Enter number5: 49
2. WAP to find out the sum of Enter array size (N): 5 Sum of the numbers
the N numbers stored in an Enter number1: 45 stored in array: 198
array of integers. Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
3. WAP to find the average of N Enter array size (N): 5 Average of the
numbers using arrays. Enter number1: 45 numbers stored in
Enter number2: 35 array = 39.6
Enter number3: 38
Enter number4: 31
Enter number5: 49
4. WAP to find largest element Enter array size (N): 5 Largest element
stored in an array. Enter number1: 45 stored in an array:
Enter number2: 35 45
Enter number3: 38
Enter number4: 31
Enter number5: 49
5. WAP to insert an element in Enter no of elements:
an 1-D array. 5 The resultant array:
12345
Enter the element to 162345
be inserted: 6
Enter the location: 2
PRACTICE ASSIGNMENT
1. WAP to search an element in Set 1: Set 1:
an 1-D array. Enter no of elements: Number found at the
5 location = 4
11 22 33 44 55
Enter the elements to
be searched: 44
Set 2: Set 2:
Enter no of elements: Number not found
5
11 22 33 44 55
Enter the elements to
be searched: 77
2. WAP to Count the total Input the number of Total number of
number of duplicate elements to be stored duplicate elements
elements in an array. in the array: 5 found in the array: 2
Input 5 elements in
the array:
element - 0: 1
element - 1: 1
element - 2: 2
element - 3: 3
element - 4: 3
3. WAP to find out the Enter array size: 5 Product of the array
multiplication of the elements = 180
numbers stored in an array Enter array elements:
of integers. 12356
4. WAP to find the second Input the size of The Second largest
largest element in an array. array: 5 element in the array
Input 5 elements in is: 6
the array:
element - 0: 2
element - 1: 9
element - 2: 1
element - 3: 4
element - 4: 6
5. WAP to delete an element at Input the size of The new list is: 1
desired position from an array: 5 24 5
array. Input 5 elements in
the array in
ascending order:
element - 0: 1
element - 1: 2
element - 2: 3
element - 3: 4
element - 4: 5
Input the position
where to delete: 3
DAY-12
TOPIC: 1-D Arrays (Contd…)
1. WAP to display the array Set-1 Set-1
elements in ascending order. Enter how many The Numbers in
numbers: 7 ascending order are
Enter the 7 Numbers: 2445678
7645248
Set-2 Set-2
Enter how many The Numbers in
numbers :10 ascending order:
Enter the 10 12 34 34 56 56 56 78
Numbers: 90 122 799
12 34 56 78 90 34 56
799 122 56
2. WAP to Print all unique Input the number of The unique elements
elements of an array. elements to be stored found in the array
in the array: 4 are:
Input 4 elements in 35
the array:
element - 0: 3
element - 1: 2
element - 2: 2
element - 3: 5
3. WAP to print all the even and Enter number of Even numbers in the
odd numbers in an 1-D elements in the array: array are: 12 98
array. 6
Enter 6 elements in Odd numbers in the
the array: 12 19 45 array are: 19 45 69
69 98 23 23
4. WAP to reverse the array Set 1: Set 1:
elements. Enter number of
elements in the array: Elements in reverse
5 order in the array:
Enter these Array 54321
Elements: 1 2 3 4 5
5. Given an array arr[] of non- Input: Sum found between
negative integers and an Enter array size: 6 and including indices
integer sum, find a Enter array elements: 2 and 4
subarray that adds to a given 1 4 20 3 10 5
sum. Enter sum = 33
PRACTICE ASSIGNMENT
1. Given an integer array, find Enter array size: 5 The peak element is
the peak element in it. A Enter array elements: 15
peak element is an element 8 9 10 12 15
that is greater than its
neighbours. There might be
multiple peak elements in an
array, and the solution
should report any peak
element.
2. Given an array A of N Enter array size: 5 3
elements. Find the majority Enter array elements:
element in the array. A 3 1 3 3 2 (Explanation:
majority element in an array Since, 3 is present
A of size N is an element that more than N/2
appears more than N/2 times times, so it is the
in the array. majority element.)
3. Given an array of integers arr[] = Output: 3 4 5 6 7 1 2
arr[] of size N and an integer {1, 2, 3, 4, 5, 6, 7},
d, the task is to rotate the d = 2
array elements to the left by
d positions.
DAY-13, DAY-14
TOPIC: 2D Arrays
Q# Experiment Details Input Output
1. WAP for a two Displaying values:
dimensional to store Enter no of Cities: 2
and display the City 1, Day 1 = 33
elements. (Store 1 2 City 1, Day 2 = 34
temperature of two City 1, Day 3 = 35
cities for a week and Enter no of days: 7 City 1, Day 4 = 33
display it) City 1, Day 5 = 32
Enter the Temp: City 1, Day 6 = 31
(Chosen values) City 1, Day 7 = 30
City 2, Day 1 = 23
City 2, Day 2 = 22
City 2, Day 3 = 21
City 2, Day 4 = 24
City 2, Day 5 = 22
City 2, Day 6 = 25
City 2, Day 7 = 26
2. WAP to find the sum of Enter elements of 1st
two matrices of order matrix Sum of Matrices:
2x2 using Enter a11: 2; 2.2 0.5
multidimensional Enter a12: 0.5;
-0.9 25.0
arrays. Enter a21: -1.1;
Enter a22: 2;
Enter elements of 2nd
matrix
Enter b11: 0.2;
Enter b12: 0;
Enter b21: 0.23;
Enter b22: 23;
3. WAP to multiply two Set-1: Set-1
matrices and display it. Enter value of matrix A Value of matrix a
111111111 111
Enter value of matrix B 111
222222222 111
Value of matrix b
222
222
222
After Multiplication
resultant matrix is
666
666
666
Set-2: Set-2
Enter value of matrix a Value of matrix a
222222222 222
Enter value of matrix b 222
333333333 222
Value of matrix b
333
333
333
After Multiplication
resultant matrix is
18 18 18
18 18 18
18 18 18
4. WAP to find the sum of Set 1: Set 1:
elements of a matrix in Enter no. of rows: 3
its upper triangle. Enter no. of cols: 3 The given matrix is:
Enter values to the 9 8 7
matrix : 6 5 4
Enter a [0][0] value: 9 3 2 1
Enter a [0][1] value: 8
Enter a [0][2] value: 7 Sum of upper triangular
Enter a [1][0] value: 6 matrix = 19
Enter a [1][1] value: 5
Enter a [1][2] value: 4
Enter a [2][0] value: 3
Enter a [2][1] value: 2
Enter a [2][2] value: 1
5. WAP to check whether Set 1: Set 1:
two matrices are equal
or not. Enter no. of rows: 3 The given matrix A is :
Enter no. of cols: 3
1 2 3
Enter values to the 4 5 6
matrix A: 7 8 9
Enter a [0][0] value: 1
Enter a [0][1] value: 2
Enter a [0][2] value: 3 The given matrix B is:
Enter a [1][0] value: 4 1 2 3
Enter a [1][1] value: 5 4 5 6
Enter a [1][2] value: 6 7 8 9
Enter a [2][0] value: 7
Enter a [2][1] value: 8
Enter a [2][2] value: 9 Matrix A is equal to Matrix
B
Enter values to the
matrix B:
Enter b [0][0] value: 1
Enter b [0][1] value: 2
Enter b [0][2] value: 3
Enter b [1][0] value: 4
Enter b [1][1] value: 5
Enter b [1][2] value: 6
Enter b [2][0] value: 7
Enter b [2][1] value: 8
Enter a [2][2] value: 9
PRACTICE ASSIGNMENT
1. WAP to check whether a Set 1: Set 1:
matrix is identity matrix
or not. Enter no. of rows: 3 The given matrix is an
Enter no. of cols: 3 Identity Matrix.
Enter values to the 1 0 0
matrix: 0 1 0
Enter a [0][0] value: 1 0 0 1
Enter a [0][1] value: 0
Enter a [0][2] value: 0
Enter a [1][0] value: 0
Enter a [1][1] value: 1
Enter a [1][2] value: 0
Enter a [2][0] value: 0
Enter a [2][1] value: 0
Enter a [2][2] value: 1
Set 2: Set 2:
Enter no. of rows: 3 The given matrix is not an
Enter no. of cols: 3 Identity Matrix.
Enter values to the 1 2 3
matrix: 0 1 0
Enter a [0][0] value: 1 0 2 1
Enter a [0][1] value: 2
Enter a [0][2] value: 3
Enter a [1][0] value: 0
Enter a [1][1] value: 1
Enter a [1][2] value: 0
Enter a [2][0] value: 0
Enter a [2][1] value: 2
Enter a [2][2] value: 1
2. WAP to find out the Set 1: Set 1:
frequency of even and
odd numbers in a Enter no. of rows: 3 The given matrix is
matrix. Enter no. of cols: 3
1 2 3
Enter values to the 4 5 6
matrix: 7 8 9
Enter a [0][0] value: 1
Enter a [0][1] value: 2
Enter a [0][2] value: 3
Enter a [1][0] value: 4 The frequency of
Enter a[1][1] value: 5 occurrence of odd number
Enter a[1][2] value: 6 =5
Enter a[2][0] value: 7
Enter a[2][1] value: 8 The frequency of
Enter a[2][2] value: 9 occurrence of even
number = 4
3. WAP to find the Set 1: Set 1:
transpose of a matrix.
The given matrix A is:
Enter no. of rows: 3 1 3 5
Enter no. of cols: 3 7 9 2
4 6 8
Enter values to the
matrix:
Enter a [0][0] value: 1 Transpose of matrix A:
Enter a [0][1] value: 3 1 7 4
Enter a [0][2] value: 5 3 9 6
Enter a [1][0] value: 7 5 2 8
Enter a [1][1] value: 9
Enter a [1][2] value: 2
Enter a [2][0] value: 4
Enter a [ 2][1] value: 6
Enter a [2][2] value: 8
4. WAP to find the Trace Enter the order of the sum of diagonal values=15
(sum of the diagonal square matrix A: 3
elements) of a given m Enter the values of
xn matrix matrix A
345
689
134
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 254, Exercise 8.3
Page No: 255, Exercise 8.5
2.
Page No: 255, Exercise 8.8
3.
4. Page No: 256, Exercise 8.14
Functions
Week 9 & 10 - Day 15,16,17,18
Day 15
Lab Assignments
Q# Experiment Details Input Output
Set 1:
Enter two
Set 1:
WAP to add two numbers number:
Sum of 17 and 10 = 27
entered through the 17 10
1. keyboard by using a
suitable user defined Set 2:
Set 2:
function. Enter two
Sum of 5 and -12 = -7
number:
5 -12
Set 1: Set 1:
WAP to find the factorial of a
Enter a number: 5 Factorial of 5 = 120
number n by using a
2.
suitable user defined
Set 2: Set 2:
function.
Enter a number: 0 Factorial of 0 = 1
A Fibonacci sequence is Set 1:
defined as follows: the first Enter Fibonacci Set 1:
and second terms in the term serial Fibonacci term serial
sequence are 0 and 1. number: 2 number: 2
Subsequent terms are found Fibonacci number: 1
by adding the preceding two
3.
terms in the sequence (Fi =
Fi-1 + Fi-2). WAP to find out Set 2: Set 2:
the value of nth term of the Enter Fibonacci Fibonacci term serial
Fibonacci sequence by term serial number: 8
writing a suitable user number: 8 Fibonacci number: 13
defined function.
Set 1:
Write a C program to Enter an integer: Set 1:
determine whether a 7 7 is prime.
4 number is prime or not
using a function named as Set 2: Set 2:
“PRIME”. Enter an integer: 6 is not prime.
6
Set 1: Set 1:
Enter num1: 10 Before Swapping
Write a C program to Enter num2: 20 num1=10
perform swapping of two num2=20
5
integers using a function
SWAP. After Swapping
num1=20
num2=10
Set 2: Set 2:
Enter num1: 15 Before Swapping
Enter num2: 30 num1=15
num2=30
After Swapping
num1=30
num2=15
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
WAP to test whether a Set 1: Set 1:
number entered through Enter the number Entered number: 10
the keyboard is a to test whether it Number is in Fibonacci
number in the Fibonacci is in Fibonacci sequence: No
sequence or not. (Using sequence or not:
1. function) 10
Set 2: Set 2:
Enter the number Entered number: 8
to test whether it Number is in Fibonacci
is in Fibonacci sequence: Yes
sequence or not: 8
WAP by designing a Set 1: Set 1:
recursive function to Enter a number: Sum of the digits (up to single
calculate the sum of the 589 digit) of 589 = 4
2. digits of any given Set 2:
integer until it becomes Set 2: Sum of the digits (up to single
a single digit number Enter a number: digit) of 25 = 7
using function. 25
WAP to print all prime Prime numbers between 1
numbers between 1 to to 100:
3 100 using function. 2, 3, 5, 7, 11, 13, 17, 19, 23,
29, 31, 37, 41, 43, 47, 53, 59,
61, 67, 71, 73, 79, 83, 89, 97
Write a function that will Set 1:
Set 1:
return the counting of No of zeros: 2
Input: 110560
Zeros in a Positive
4. Integer
Set 2:
Set 2:
No of zeros: 0
Input: 178655
WAP to test whether a Set 1: Set 1:
number n is Enter a number to Entered number: 123
5.
palindrome number or test for Number is not palindrome.
not. palindrome: 123
Set 2: Set 2:
Enter a number to Entered number: 1551
test for Number is palindrome.
palindrome: 1551
Day: 16
TOPIC: Functions with 1D Arrays
Lab Assignments
Q# Experiment Details Input Output
Set 1: Set 1:
Enter the size of the Sum of the elements of the
array: 5 given array: 23
Enter the elements of
WAP to design a user
the array: 3 5 7 2 6
defined function to
1. calculate the sum of the
Set 2: Set 2:
elements of an integer 1-
Enter the size of the Sum of the elements of the
D array.
array: 3 given array: 3
Enter the elements of
the array: 5 0 -2
Set 1:
Set 1:
Enter the size of the
Before sorting elements of
array: 5
the given array: 3 5 7 2 6
WAP to sort the elements Enter the elements of
After sorting elements of
of an 1-D array in the array: 3 5 7 2 6
the given array: 2 3 5 6 7
ascending order by using
2. Set 2:
a suitable user defined Set 2:
Before sorting elements of
function for sort Enter the size of the
the given array: 5 0 -2
operation. array: 3
After sorting elements of
Enter the elements of
the given array: -2 0 5
the array: 5 0 -2
Set 1: Set 1:
Enter the size of the Largest element of array is
Write a C program to array: 5 7
determine the largest Enter the elements of Smallest element of array is
and smallest element of the array: 3 5 7 2 6 2
3. a 1-D array. Use
functions LARGEST and Set 2: Set 2:
SMALLEST for the given Enter the size of the Largest element of array is
purpose. array: 3 5
Enter the elements of Smallest element of array is
the array: 5 0 -2 -2
Set 1:
Enter the size of the
Set 1:
array: 5
Second largest element of
Write a C program to Enter the elements of
array is 6
determine the second the array: 3 5 7 2 6
4. largest element of a 1-D
array of using a function Set 2:
Set 2:
SECLARGEST. Enter the size of the
Second largest element of
array: 3
array is 0
Enter the elements of
the array: 5 0 -2
Set 1:
Enter the size of the Set 1:
array: 5 Entered array: 3 5 7 2 6
Enter the elements of Array after swapping: 6 5 7
Write a C program to the array: 3 5 7 2 6 23
swap the first and last
5.
element of a 1-D array of Set 2:
using a function SWAP. Enter the size of the Set 2:
array: 3 Entered array: 5 0 -2
Enter the elements of Array after swapping: -2 0
the array: 5 0 -2 5
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
Write a C program to Set 1:
swap the largest and Enter the size of the Set 1:
smallest element of a array: 5 Entered array: 3 5 7 2 6
1-D array of using a Enter the elements of Array after swapping: 3 5 2
function SWAP. the array: 3 5 7 2 6 76
1. Set 2:
Enter the size of the
array: 3 Set 2:
Enter the elements of Entered array: 5 0 -2
the array: 5 0 -2 Array after swapping: -2 0 5
Write a C program to Set 1: Set 1:
find the sum of only Enter the size of the Sum of odd values = 15
odd values in a 1-D array: 5 Set 2:
array using a function Enter the elements Sum of odd values = 5
2. ODDSUM. of the array: 3 5 7 2
6
Set 2:
Enter the size of the
array: 3
Enter the elements
of the array: 5 0 -2
Write a C program to Set 1: Set 1:
find the sum of only Enter the size of the Sum of prime values = 15
PRIME values in a 1-D array: 5 Set 2:
array using a function Enter the elements of Sum of prime values = 5
PRIMESUM. the array: 3 5 7 2 6
3.
Set 2:
Enter the size of the
array: 3
Enter the elements of
the array: 5 0 -2
Day: 17
TOPIC: Functions with 2D Arrays
Lab Assignments
Q# Experiment Details Input Output
Set 1:
Enter the row and
column size of the
matrix: 3 4
Enter the matrix:
Set 1:
4 56 2
Sum of the elements
1 93 0
of the given array: 44
Write a C program to 7 -2 1 8
determine the sum of
1. elements of a 2-D array Set 2:
using a function Enter the row and
Set 2:
ELESUM. column size of the
Sum of the elements
matrix: 5 3
of the given array: 38
Enter the matrix:
5 6 2
4 3 0
-7 1 8
4 4 5
0 3 0
Write a C program to Set 1: Set 1:
determine the sum of Enter a 3x3 size matrix: Sum of the main
2. main diagonal elements 1 2 3 diagonal elements of
of a 2-D array of size 3x3 4 5 6 the given array: 15
using a function 7 8 9
SUMDIAGONAL. Set 2: Set 2:
Enter a 3x3 size matrix: Sum of the elements
111 of the given array: 6
222
333
Set 1:
Enter the row and
column size of the
matrix: 3 4
Set 1:
Enter the matrix:
Largest element of
4 56 2
array is 9
Write a C program to 1 93 0
Smallest element of
determine the largest 7 -2 1 8
array is -2
and smallest element of
3. a 2-D array. Use Set 2:
functions LARGEST and Enter the row and
Set 2:
SMALLEST for the given column size of the
Largest element of
purpose. matrix: 5 3
array is 8
Enter the matrix:
Smallest element of
5 6 2
array is -7
4 3 0
-7 1 8
4 4 5
0 3 0
Set 1:
Enter the row and
column size of the
matrix: 3 4
Enter the matrix: Set 1:
4 56 2 Sum of prime
1 93 0 elements = 17
Write a C program to find
7 -2 1 8
the sum of only PRIME
values in a 2-D array
4. Set 2:
using a function
Enter the row and
PRIMESUM.
column size of the Set 2:
matrix: 5 3 Sum of prime
Enter the matrix: elements = 18
5 6 2
4 3 0
-7 1 8
4 4 5
0 3 0
Write a C program to Set 1:
perform addition of two Enter matrix1: Set 1:
matrices and display the 1 2 3 Result matrix
5.
result using 3rd matrix. 4 5 6 234
Use a function 7 8 9 678
ADDMATRIX Enter matrix2: 10 11 12
111
222
333
Set 2:
Enter matrix1: Set 2:
123 Result matrix
-4 5 -6 234
7 -8 9 -3 6 -5
Enter matrix2: 8 -7 10
111
111
111
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
Write a C program to Set 1:
determine the sum of Enter the row and
largest and smallest column size of the
element of a 2-D array. matrix: 3 4
Use a function SUMLS Enter the matrix:
4 56 2 Set 1:
1 93 0 Sum of largest and smallest
7 -2 1 8 elements: 7
1. Set 2:
Enter the row and Set 2:
column size of the Sum of largest and smallest
matrix: 5 3 elements: 1
Enter the matrix:
5 6 2
4 3 0
-7 1 8
4 4 5
0 3 0
Write a C program to Set 1: Set 1:
swap the largest and Enter the row Entered matrix
smallest element of a and column 4562
2-D array of using a size of the 1930
function SWAP. matrix: 3 4 7 -2 1 8
Enter the
matrix: Matrix after swapping
2.
4 56 2 4562
1 93 0 1 -2 3 0
7 -2 1 8 7918
Set 2:
Entered matrix
562
Set 2: 430
Enter the row -7 1 8
and column 445
size of the 030
matrix: 5 3
Enter the Matrix after swapping
matrix: 562
5 6 2 430
4 3 0 8 1 -7
-7 1 8 445
4 4 5 030
0 3 0
Write a C program to Set 1: Set 1:
sort the elements of a Enter the row Entered matrix
values in a 2-D array and column size 4562
using a function of the matrix: 3 1930
SORTELE. 4 7 -2 1 8
Enter the
matrix: Matrix after
4 56 2 sorting
1 93 0 -2 0 1 1
7 -2 1 8 2345
6789
Set 2:
Enter the row Set 2:
3. and column size Entered matrix
of the matrix: 5 562
3 430
Enter the -7 1 8
matrix: 445
5 6 2 030
4 3 0
-7 1 8 Matrix after
4 4 5 sorting
0 3 0 -7 0 0
012
334
445
568
Write a C program to Set 1: Set 1:
perform multiplication of Enter matrix1: Entered matrix1:
two matrices of size 3x3 234 234
and display the result 356 356
using 3rd matrix. 453 453
4
Enter matrix2: Entered matrix2:
121 121
-1 2 1 -1 2 1
321 321
Result matrix
11 18 9
16 28 14
8 24 12
Set 2: Set 2:
Enter matrix1: Enter matrix1:
231 231
741 741
9 -2 1 9 -2 1
Enter matrix2: Enter matrix2:
9 -2 -1 9 -2 -1
573 573
810 810
Result matrix
41 18 7
91 15 5
79 -31 -15
Day 18
Recursion
Lab Assignments
Q# Experiment Details Input Output
Set 1: Set 1:
WAP to find the factorial
Enter a number: 4 Factorial of 4 = 24
of a number n by writing
1.
a recursive function for
Set 2: Set 2:
it.
Enter a number: 1 Factorial of 1 = 1
Set 1:
Set 1:
Enter two numbers:
WAP to calculate GCD of 105 and 60 = 15
105 60
GCD/HCF of two
2.
numbers by using a
Set 2:
recursive function. Set 2:
Enter two numbers:
GCD of 5 and 70 = 5
5 70
WAP by designing a Set 1: Set 1:
recursive function to Enter a number: 589 Sum of the digits (up to
calculate the sum of the single digit) of 589 = 4
3.
digits of any given Set 2: Set 2:
integer until it becomes Enter a number: 25 Sum of the digits (up to
a single digit number. single digit) of 25 = 7
Write a recursive Set 1: Set 1:
function to add the Input: 13478635 Sum of digits: 37
4
digits of a positive
integer.
Set 2: Set 2:
Input: 5875014 Sum of digits: 30
Set 1: Set 1:
Enter the size of the Entered Array: 3 5 7 2 6
array: 5 Maximum elements of the
Enter the elements of given array: 7
WAP to find out the
the array: 3 5 7 2 6
maximum element of an
5
integer array by using
Set 2: Set 2:
recursion.
Enter the size of the Entered Array: 5 0 -2
array: 3 Maximum elements of the
Enter the elements of given array: 5
the array: 5 0 -2
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
WAP to count number Set 1: Set 1:
of digits of a positive Enter a number: Number of digits of 10 = 2
integer n by using a 10
1.
recursive function. Set 2: Set 2:
Enter a number: Number of digits of 2105 = 4
2105
WAP to find the nth Set 1: Set 1:
Fibonacci number Enter the value of n = 10
using recursion. n: 10 nth Fibonacci number =
34
2.
Set 2: Set 2:
Enter the value of n=4
n: 4 nth Fibonacci number = 2
Write a recursive Set 1: Set 1:
function to reverse a Input: Hello Output: olleH
null terminated string
3
Set 2: Set 2:
Input: I am going to Output: .loohcs ot gniog ma I
school.
Write a recursive Input: Please Enter Output: Elements of Second
function to copy one the Array Size: 5 Array are:
array to another. Please Enter the
Array Elements: 3 Value Inside Array b[0] = 3
4.
5 Value Inside Array b[1] = 5
7 Value Inside Array b[2] = 7
8 Value Inside Array b[3] = 8
9 Value Inside Array b[4] = 9
Write a recursive Set 1: Set 1:
function to convert a Input: 765 Output: 1011111101
5.
decimal number to Set 2: Set 2:
binary Input: 123 Output: 1111011
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 344, Exercise 10.3
Page No: 344, Exercise 10.9
2.
Page No: 345, Exercise 10.14
3.
Character Arrays/Strings
Week 11 - Day 19, 20
Lab Assignments
Q# Experiment Details Input Output
1. WAP to find the length of a Enter a string: Length of the entered
string with/without using Programming String is 11
library function for getting
length of the string
2. Write a program to extract Enter a weu
last character of every word sentence:
present in a sentence. How are You
3. Write a program to Enter String 1: KIIT University
concatenate two strings KIIT
without using any library Enter String 2:
function. University
4. Write a program to check Set1: Kalinga Set1: Not Palindrome
whether an entered string is
palindrome or not. Set2: Madam Set2: Palindrome
5. Write a C program to extract Industrial 2 4 dust
a substring from a given
string. Prompt the user to
enter the starting position
and length of the substring.
6. Write a C program to find the You are very very
first largest word in a given good boy.
sentence. Assume that words
are separated by spaces.
7. Write a program to count the This is the best Vowels=3,
number of vowels, university. consonants=9, new
consonants, new lines and lines=1, total number of
the total number of characters=23, Total
characters and words present words=5.
in a string.
8. Write a program to count the Hello World H=1, e=1, l=3, o=2, w=1,
frequency of each character r=1, d=1
present in a string.
9. Write a program to replace all Hello World, HeHeo Worod
the occurrence of a particular character= l
character in a string by its
previous 3rd character, If any.
10. Write a C program to remove Hello world Hello world
all leading and trailing spaces
from a given string, if any.
11. Write a C program to replace You are a very You are a very good boy
multiple occurrences of a very good boy
specific word present in a
given sentence with a single
occurrence.
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
1 Write a C program to capitalize Kalinga institute of Kalinga Institute Of
the first letter of each word in a industrial Industrial Technology
given sentence. Assume that technology
words are separated by spaces.
2 Write a C program to check if a Case 1: Case 1:
given string is a valid email student@[Link]
address. Use appropriate This email Id is valid
validation criteria, such as the Case 2: Case 2:
presence of '@' and '.' symbols. [Link] This email Id is not
valid
3 Write a C program to check if String 1: worth Two strings are
two strings are anagrams. String 2: throw anagrams.
(An anagram is a word or phrase
formed by rearranging the letters
of another word or phrase.)
4 Write a C program to remove all College Coleg
duplicate characters from a
given string. The resulting string
should contain each character
only once.
5 Write a C program to reverse the Hello World World Hello
order of words in a
givensentence.
6. Write a C program to remove all aaabbbcccdddeee abcde
consecutive duplicate characters
from a given string.
7. Write a C program to find the Institute Instu
common characters between two Industrial
strings. Display the common
characters in alphabetical order.
8. Write a C program to compare Case 1:kiit kiit Case 1: 0
two strings without using the Case 2:kite bite Case 2: 9
built-in strcmp() function.
9. Write a C program to convert a "12345" 12345
string of digits into an integer
value.
10. Write a C program to remove all Hello World Hll Wrld
vowels from a given string.
Consider both uppercase and
lowercase vowels.
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 288, Exercise 9.7
Page No: 289, Exercise 9.9
2.
Page No: 289, Exercise 9.10
3.
Pointer, Dynamic Memory Allocation
Week 12, 13 - Day 21, 22, 23
Lab Assignments
Q# Experiment Details Input Output
1 WAP to multiply two 5 30
numbers using 6
pointers.
2 WAP to swap two Enter value of a: 8 After swap,
numbers using call by Enter value of b: 10 The value of a: 10
reference. Enter value of b: 8
3 WAP to compute the No. Of elements: 3 Sum=6
sum of all elements in 1
an array using pointer. 2
3
4 WAP to print a string Set 1: Set 1:
in reverse using a Input a string: KIIT Reverse of the string is:
pointer. TIIK
Set 2: Set 2:
Input a string: MADAM Reverse of the string is:
MADAM
5 WAP to count vowels Set 1: Set 1:
and consonants in a Input a string: Number of vowels in
string using pointer. HelloWorld String: 3
Number of Consonants
in String: 7
Set 2: Set 2:
Input a string: string Number of vowels in
String:1
Number of Consonants
in String: 5
6 WAP to sort an array Set 1: Set-1:
using Pointer. Enter the number of The elements in the
elements to store in the array after sorting :
array: 5 element - 1: 15
Enter 5 number of element - 2: 25
elements in the array: element - 3: 45
element - 1: 25 element - 4: 82
element - 2: 45 element - 5: 89
element - 3: 89
element - 4: 15
element - 5: 82
Set 2:
Enter the number of Set-2:
elements to store in the The elements in the
array: 6 array after sorting:
Enter 6 number of element - 1: 12
elements in the array: element - 2: 15
element - 1: 75 element - 3: 39
element - 2: 45 element - 4: 45
element - 3: 39 element - 5: 75
element - 4: 15 element - 6: 92
element - 5: 92
element - 6: 12
7 WAP to compute the No. Of elements: 3 Sum=6
sum of all elements in 1
an array using 2
dynamic memory 3
allocation.
8 WAP to find the largest Set-1: Set-1:
element stored in an Enter the total number Largest number is 24.20
array of n elements by of elements: 5
using dynamic Number1: 3.4
memory Number2: 2.4
allocation. Number3: -5
Number4: 24.20
Number5: 6.7
Set-2: Set-2:
Enter the total number Largest number is 56
of elements: 4
Number1: 8
Number2: 14
Number3: 56
Number4: 34
8. Dynamically allocate Enter number ofEnter number of
the size of an array elements: 5 elements: 5
using calloc, insert Enter the elements of Memory successfully
elements into the the array are: 1 2 3 4 5 allocated using calloc.
array, then print the The elements of the array
elements. Change the Enter the new size of the are: 1, 2, 3, 4, 5,
size of the array, get array: 10
the new elements and Enter new elements of Enter the new size of the
print the array. Finally the array: 6 7 8 9 10 array: 10
free the memory. Memory successfully re-
allocated using realloc.
The elements of the array
are: 1, 2, 3, 4, 5, 6, 7, 8,
9, 10,
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
1 WAP to swap three numbers Set-1: Set-1:
in cyclic order using Call by Enter a, b and c Value before
Reference. In other words, respectively: 1 swapping:
WAP that takes three 2 a=1
variables (a, b, c) as 3 b=2
separate parameters and c=3
rotates the values stored so Value after swapping:
that value a goes to b, b to c a=3
and c to a. b=1
c=2
Set-2: Set-2:
Enter a, b and c Value before
respectively: 5 swapping:
6 a=5
7 b=6
c=7
Value after swapping:
a=7
b=5
c=6
2 WAP to change the value of Set-1: Set-1:
constant integer using Before changing - After changing - value
pointers. value of a: 10 of a: 20
Set-2: Set-2:
Before changing - After changing - value
value of a: 50 of a: 60
3 WAP to count distinct Enter the string: Consonants are:
number of vowels and Java J-1
consonants present in a v-1
string using pointer. Vowels are:
a-2
4 WAP to swap two Set-1: Set-1:
consecutive characters Enter a String: help String: ehpl
starting from left to right of
a string. Set-2: Set-2:
Enter a String: Hello The length of the
string is Odd.
5 Dynamically allocate Enter number of Memory successfully
memory using malloc() and elements: 5 allocated using
calloc(). malloc.
Check if the memory has Malloc Memory
been successfully allocated successfully freed.
by malloc or not. Memory successfully
Check if the memory has allocated using calloc.
been successfully allocated Calloc Memory
by calloc or not. successfully freed.
Finally Free the memory.
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 419, Exercise 12.2
Page No: 419, Exercise 12.4
2.
Page No: 419, Exercise 12.9
3.
User Defined Data Types –Structures and Unions
Week 13, 14 - Day 24, 25, 26
Day 24: Lab Assignments
Q# Experiment Details Input Output
1. WAP to store one Enter the students’ data: The student’s details are:
student’s information Roll Number: 1505201 Roll Number: 1505201
(i.e. student’s roll no, Name: Rajesh Agarwal Name: Rajesh Agarwal
name, gender, marks Gender: M Gender: M
etc) of an Marks: 95 Marks: 95
educational institute
and display all the
data, using structure
2. WAP to store n Set 1: Set 1:
students’ information Enter the number of The students details are
(i.e. student’s roll no, students: 1 Roll Number: 1505201
name, gender, marks Enter the students’ data: Name: Rajesh Agarwal
in 5 subjects Roll Number: 1505201 Gender:M
etc) of an educational Name: Rajesh Agarwal Mark in subject 1:95
institute and display Gender: M Mark in subject 2: 85
all the data with total Mark in subject 1:95 Mark in subject 3: 75
marks of each Mark in subject 2: 85 Mark in subject 4: 65
student, using Mark in subject 3: 35 Mark in subject 5: 55
array of structure. If Mark in subject 4: 65 Total marks: 375
full mark of each Mark in subject 5: 55 List of fail students: 1
subject is considered
as 100 and pass Enter subject number
mark as 40, then whose failed list to be
display the list of displayed: 3
students failed in a
particular subject. Set 2: Set 2:
Enter the number of The students’ details are
students: 2 Roll Number: 1505201
Enter the students’ data: Name: Rajesh Agarwal
Roll Number: 1505201 Gender: M
Name: Rajesh Agarwal Mark in subject 1:95
Gender: M Mark in subject 2: 85
Mark in subject 1:95 Mark in subject 3: 50
Mark in subject 2: 85 Mark in subject 4: 30
Mark in subject 3: 50 Mark in subject 5: 55
Mark in subject 4: 30 Total marks: 315
Mark in subject 5: 55
Enter the students’ data: Roll Number: 1505202
Roll Number: 1505202 Name: Yashraj Behera
Name: Yashraj Behera Gender: M
Gender: M Mark in subject 1:90
Mark in subject 1:90 Mark in subject 2: 80
Mark in subject 2: 80 Mark in subject 3: 45
Mark in subject 3: 45 Mark in subject 4: 35
Mark in subject 4: 35 Mark in subject 5: 75
Mark in subject 5: 75 Total marks: 325
Enter subject number List of fail students: 2
whose failed list to be
displayed: 4
3. WAP to add two Set-1 Set-1
distances (in km- Enter data for 1st
meter) using distance: Sum of distances = 14 km
structures. Enter km: 6 100 m
Enter meter: 600
Enter data for 2nd
distance
Enter km: 7
Enter meter: 500
Set-2 Set-2
Enter data for 1st Sum of distances = 16 km
distance: 200 m
Enter km: 7
Enter meter: 700
Enter data for 2nd
distance
Enter km: 8
Enter meter: 500
4. WAP to add two Set-1 Set-1
times (in hr-min-sec) Enter Time 1 -> 3: 40 : 50
by passing structure Enter Time 2 -> 2: 45: 50 Sum of time is -> 6: 26:
to a function. Set-2 40
Enter Time 1 -> 5: 10: 45 Set-2
Enter Time 2 -> 6: 40: 45
Sum of time is ->11: 51:
30
5. WAP to store n Set-1 Set-1
employees’ data such Enter the number of
as employee name, employees: 3 Details of Employee-
gender, designation, Enter Employee details- Name: John Doe
department, basic Enter employee name: Gender: M
pay etc using John Doe Designation: Manager
structures with Enter employee gender Department: Sales
dynamically memory (M/F): M Basic Pay: 50000.00
allocation. Calculate Enter employee Gross Pay: 87500.00
the gross pay of each designation: Manager
employee as follows: Enter employee Details of Employee-
Gross pay=basic pay department: Sales Name: Jane Smith
+ HR + DA Enter employee basic pay: Gender: F
HR=25% of basic, 50000 Designation: Engineer
DA=75% of basic Department: Engineering
Enter Employee details- Basic Pay: 35000.00
Enter employee name: Gross Pay: 61250.00
Jane Smith
Enter employee gender Details of Employee-
(M/F): F Name: Alex Johnson
Enter employee Gender: M
designation: Engineer Designation: Analyst
Enter employee Department: Finance
department: Engineering Basic Pay: 45000.00
Enter employee basic pay: Gross Pay: 78750.00
35000
Enter Employee details-
Enter employee name:
Alex Johnson
Enter employee gender
(M/F): M
Enter employee
designation: Analyst
Enter employee
department: Finance
Enter employee basic pay:
45000
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
1 WAP to create a new data Set-1 Set-1
type DATE (dd-mm-yyyy)
with the help of structure Enter a date: 24- Next day is : 25-03-2023
and typedef. Write the 03-2023 Next month : 24-04-2023
following user defined No. of days to add: Next year is : 24-03-2024
functions for the date 9 After addition of days :
manipulations. No. of months to 2-04-2023
a) To increment date by 1 day add: 2 After addition of months :
b) To increment date by 1 No. of years to add 24-05-2023
month :3 After addition of years :
c) To increment date by 1year 24-03-2026
d) to add few days in a date. Month name : March
e) To add few months in a Date : 24.03.23
date.
f) To add few years in a date.
g) To return month name
from a date.
h) To display date in DD-MM-
YY format
Day: 25
TOPIC :Structure and Union
Lab Assignments
Q# Experiment Details Input Output
1 WAP to declare an Set-1 Set-1
union named as ABC Values entered one by one: Character: A
having three Enter a character: A Integer: 42
members a, b and c Enter an integer: 42 Double: 3.140000
as character, integer Enter a double: 3.14
and double
respectively. Assign Set-2 Set-2
user entered values to Enter a character, an Values entered all
these members integer, and a double all together:
respectively one by together: character: @
one and display these A integer: 10586
values immediately. 42 double: 3.14
Again, assign these 3.14
user entered values to
a, b, c one by
one, all together and
display these values
at last. Find the
difference.
2 Use structures to Set-1 Set-1
perform addition, Enter the real and You have entered 1st no.
subtraction, imaginary units of first As = 7.0 + 8.0 i
multiplication and complex number: You have entered 2nd no.
division operations on First real = 7 As = 3.0 + 6.0 i
two complex First Imaginary = 8
numbers. Enter the real and What do you want to do?
imaginary units of the Press e for exit
second complex number: Press a for addition
Second real = 3 Press s for subtraction
Second Imaginary = 6 Press m for multiplication
Press d for division: a
Your ans is:
10.0 + 14.0 i
What do you want to do?
Press e for exit
Press a for addition
Press s for subtraction
Press m for multiplication
Press d for division: s
Your ans is:
4.0 + 2.0 i
What do you want to do?
Press e for exit
Press a for addition
Press s for subtraction
Press m for multiplication
Press d for division: m
Your ans is:
-27.0 + 66.0 i
What do you want to do?
Press e for exit
Press a for addition
Press s for subtraction
Press m for multiplication
Press d for division: d
Your ans is:
1.5 + 0.4 i
What do you want to do?
Press e for exit
Press a for addition
Press s for subtraction
Press m for multiplication
Press d for division : e
3 Use an array of Set-1 Set-1
structures to
calculate the gross What do you want to do? Enter employee details:
salary and solve the A. Enter new employee First Name: Arjun
increment issue in an details: Last Name: Mohanty
office. Also, calculate B. Search employee details: Enter Category: Clerk
the new salary C. Increment the salary: A Enter Address: Patia
structure after Square, Kalarahanga
increment. Given What do you want to do? Enter Basic Salary:
basic: Rs 12500, DA: A. Enter new employee 12500
50%, and HRA 10%. details:
B. Search employee details:
C. Increment the salary: B Enter First Name: Arjun
What do you want to do? Name: Arjun Mohanty
A. Enter new employee Address: Patia Square,
details: Kalarahanga
B. Search employee details: Gross Salary: 20000
C. Increment the salary: C
Enter First Name: Arjun
What do you want to do? Percentage Increase: 10
A. Enter new employee
details: Enter First Name: Arjun
B. Search employee details:
C. Increment the salary: B Name: Arjun Mohanty
Address: Patia Square,
Kalarahanga
Gross Salary: 22000
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
1 WAP to calculate the Set-1 Set-1
difference between two time Enter Choice :
periods. Times are given in 1. 12 hr format Difference between
(hr:min:sec) User has to 2. 24 hr format Time 1 and Time 2 is-
choose whether 12hr or 24 1 3 hrs 15 mins 20 secs
hr format. Enter time1-
09:25:30
Enter time 2-
06:10:10
Set-2 Set-2
Enter Choice:
1. 12 hr format Difference between
2. 24 hr format Time 1 and Time 2 is-
2 1 hrs 10 mins 5 secs
Enter time1-
14:20:10
Enter time2-
13:10:05
3 WAP to extract individual Set-1 Set-1
bytes from an unsigned int Enter an unsigned Individual bytes: FF
using union. integer: 4294967295 FF FF FF
Set-2 Set-2
Enter an unsigned Individual bytes: 31
integer: 987654321 2D FB 3A
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 378, Exercise 11.4
Page No: 379, Exercise 11.7
2.
Page No: 380, Exercise 11.12
3.
File Handling
Lab Assignments
Week 15 : Day 27, 28
Q# Experiment Details Input Output
1 WAP to read and print Content of [Link] From the small
the content of a file From the small beginnings KIIT has
[Link] beginnings KIIT has developed into a leading
developed into a university
leading university
2 WAP to write the text Content of [Link]
From the small From the small
beginnings KIIT has beginnings KIIT has
developed into a leading developed into a leading
university into a file university
[Link]
3 WAP to append the Content of [Link] Content of [Link]
phrase “with a strong From the small From the small
interdisciplinary culture beginnings KIIT has beginnings KIIT has
and a commitment to developed into a developed into a leading
teaching excellence” into leading university university with a strong
the file [Link] interdisciplinary culture
and a commitment to
teaching excellence
4 WAP to count the total Content of [Link] 150
number of characters in From the small
the file [Link] beginnings KIIT has
developed into a
leading university with
a strong
interdisciplinary
culture and a
commitment to
teaching excellence
5 WAP to count the total Content of [Link] 22
number of words in the From the small
file [Link] beginnings KIIT has
developed into a
leading university with
a strong
interdisciplinary
culture and a
commitment to
teaching excellence
6 WAP to change all small Content of [Link] Content of [Link]
letters in the file [Link] From the small FROM THE SMALL
to capital letters beginnings KIIT has BEGINNINGS KIIT HAS
developed into a DEVELOPED INTO A
leading university with LEADING UNIVERSITY
a strong WITH A STRONG
interdisciplinary INTERDISCIPLINARY
culture and a CULTURE AND A
commitment to COMMITMENT TO
teaching excellence TEACHING EXCELLENCE
7 WAP to copy contents of Content of [Link] Content of [Link]
the file [Link] to FROM THE SMALL FROM THE SMALL
another file [Link] BEGINNINGS KIIT HAS BEGINNINGS KIIT HAS
DEVELOPED INTO A DEVELOPED INTO A
LEADING UNIVERSITY LEADING UNIVERSITY
WITH A STRONG WITH A STRONG
INTERDISCIPLINARY INTERDISCIPLINARY
CULTURE AND A CULTURE AND A
COMMITMENT TO COMMITMENT TO
TEACHING TEACHING EXCELLENCE
EXCELLENCE
8 Write all the programs 1- Same as previous Same as previous
7 where all the related
filenames will be given at
command line
Home Assignments (Practice Problems)
Q# Experiment Details Input Output
1 WAP to generate Content of [Link] Content of [Link]
factorial of number 5 5
given as input 120
through a file [Link]
and append the
factorial value in the
file.
2 WAP to count the Content of [Link]
case-insensitive From the small beginnings KIIT
occurrences of a given has developed into a leading
word in a file [Link] university with a strong
interdisciplinary culture and a
commitment to teaching
excellence
Set 1 Set 1
Input the word to search: a 3
Set 2 Set 2
Input the word to search: THE 1
3 WAP to count total Set 1 Set 1
number of words in Content of [Link] Paragraph -1 words
each paragraph in a From the small beginnings KIIT – 22
file [Link] has developed into a leading
university with a strong
interdisciplinary culture and a
commitment to teaching
excellence
4 Check if contents of Set 2 Set 2
two files are same Content of [Link] Paragraph -1 words
From the small beginnings – 22
KIIT has developed into a Paragraph -2 words
leading university with a strong - 12
interdisciplinary culture and a
commitment to teaching
excellence.
Today, KIIT offers
professional education to
around 35,000 students from
across India.
5 WAP to check if there Set 1 Set 1
exists any date in dd- Content of [Link] YES
mm-yyyy format in a Today date is 01-01-2023
file [Link]
Set 2 Set 2
Content of [Link] NO
Today date is 1st January of
2023
6 WAP to check if a Set 1 Set 1
filepath, given as the [Link] Filepath doesnot
commandline exist
argument, exists in
the system Set 2 Set 2
[Link] Filepath exists
7 WAP to delete a file if Set 1 Set 1
that exists in the [Link] Filepath doesnot
system, where the exist
filepath is given as
the commandline Set 2 Set 2
argument [Link] Fie deleted
successfully
Home Assignments (Book Exercises)
Q# Experiment Details
1. Page No: 444, Exercise 13.7
Page No: 444, Exercise 13.8
2.
Grading Policies:
Assessment Weightage /
Sl Internal/Sessional
Component Marks
No.
Continuous Evaluation 15
Pre-Mid
Lab Report + Attendance
Sem
Viva/Quiz/Programming Test 15
1 Internal
(60 Marks) Continuous Evaluation 15
Post-Mid
Lab Report + Attendance
Sem
Viva/Quiz/Programming Test 15
Quiz 20
2 Sessional
(40 Marks) Programming Test 20
Reference Materials:-
1. Text books
T1: Programming in ANSI C (8th Edition) by E. Balagurusamy
2. Reference books
R1: The C Programming Language by Brian Kernighan and Dennis Ritchie
(Second Edition)
3. Links to e-resources (NPTEL, YouTube, Swayam, Virtual lab etc)
[Link]