0% found this document useful (0 votes)
6 views55 pages

Programming Lab Lessson Plan 2024 Autumn (1)

C practice
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)
6 views55 pages

Programming Lab Lessson Plan 2024 Autumn (1)

C practice
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/ 55

School of Computer Engineering

KIIT deemed to be University


Laboratory Lesson Plan – Autumn’2024 (2nd Semester)

Discipline: Computer Science and Engineering

Course name and Code: PROGRAMMING LABORATORY (CS13001)

(L-T-P-Cr: 0-2-4-4)

Instructor Name:

Instructor Chamber:

Sr Details Week#
#

Fundamentals of computer, Number systems and basic Linux


1 1
commands.

Practice and write programs on simple input and output


2 2
operations.

3 Practice and write programs on Operators and Expressions. 2

4 Practice and write programs on branching statements (if-else). 3

5 Practice and write programs on looping (control) statements. 4, 5

6 Practice and write programs on Arrays. 6,7

Mid Sem Exam


7 8
30th September-7th October

8 Practice and write programs on Functions 9, 10

9 Practice and write programs on Character Array 11

10 Practice and write programs on Pointers 12, 13

11 Practice and write programs on Structures and Unions 13, 14

12 Practice simple programs on file handling 15

Sessional Exam
13
1st December-7th December
Technical Assistants Names: Prasanta Kumar Sahoo, Ruchika
Katyani

Course Contents: Week-wise lesson plan

List of Experiments (Day wise):

Introduction To Programming, Linux Commands

Week1- Day 1, Day2

Introduction to computer fundamentals, memory


Flow chart, algorithm
Number system representation (Binary-decimal) and numerical
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
a triangle who’s base the 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 Enter num1: 10 num1=10, num2=20
5
two integers using a Enter num2: 20 After Swapping
third 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 Enter num2: 20 num1=10
two integers without num2=20
1. using a 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
into its equivalent hour, Enter the time:7560
1. Hour, 27 Minute and
minute and second as per the second.
40 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
Enter the marker
entered through keyboard.
price: 100. Set 1:
Sometimes seller gets profit
Enter the discount: Seller made a loss of
or sometimes loss depending
25% 6.25%.
5. upon the discount. WAP to
Set 2:
determine whether the seller
Enter the buying Set 2:
has made profit or incurred
price: 80 Seller made a profit of
loss. Also determine how
Enter the marker 12.50%.
much profit he made or loss
price: 100.
he incurred.
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
3. WAP to add two times in Enter two times: Output time is
hour, minute & second 11:45:34 and 09:28:41 21:14:15
format entered through the [Input must be taken in
keyboard in the format such a way so that sum
hh:mm:ss 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 Set 1: Set 1:


whether a year entered Enter the year:2005 2005 is not a leap
through the keyboard is a year.
leap year or not. Set 2:
Enter the year:1996 Set 2:
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. Secured grade is C Secured grade is O
Use 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 1 2
switch-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 Input the marks The candidate is not
for admission based on the obtained in eligible for admission.
following criteria: Physics :65
Input the marks
Eligibility Criteria: obtained in
Marks in Maths >=65 and Marks Chemistry :51
in Phy >=55 and Marks in Input the marks
Chem>=50 and obtained in
Total in all three subjects >=190 Mathematics :7
or Total in Maths and Physics 2
>=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 Set 2 Set 2
input). 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 Set 1 Set 1
of a number. n=234 The reverse of 234 is
Set 2 432
n=1235 Set 2
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 Set 1 Set 1
is Armstrong Number or not. n=153 The given number is
(A number is said to be Armstrong
Armstrong when the sum of Set 2 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 Set 1 Set 1
is 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
(A number is said to be Perfect is not Perfect
when the sum of factors
excluding the number itself is Set 2
Set 2
equal to the original number.
The given number
n=28 is 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
variation onb the Fibonacci be generated: 7 1 3 4 7 11 18 29
sequence are:

1 3 4 7 11 18 29 …

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
n=121 is 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)+... value of n: 4
+(1+2+3+...+n)

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 Enter the The sum of series is
n terms value of n: 873612.0
1+22+33+……….+nn 7
2. WAP to find out sum of series up to Enter the The sum of series is
n terms value of n: 13.477573
7

3. WAP to print the following pattern Enter Row 1 1 1 1


for rows = 4 Number: 4 22 2 2
1111 33 3 3
2222 44 4 4
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): Array Contents are:
can store N integers and 5 45 35 38 31 49
display the contents of the Enter number1: 45
array Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
2. WAP to find out the sum of Enter array size (N): Sum of the numbers
the N numbers stored in an 5 stored in array: 198
array of integers. Enter number1: 45
Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
3. WAP to find the average of N Enter array size (N): Average of the
numbers using arrays. 5 numbers stored in
Enter number1: 45 array = 39.6
Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
4. WAP to find largest element Enter array size (N): Largest element
stored in an array. 5 stored in an array:
Enter number1: 45 45
Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
5. WAP to insert an element in Enter no of
an 1-D array. elements: 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 Number found at the
elements: 5 location = 4
11 22 33 44 55
Enter the elements
to be searched: 44
Set 2: Set 2:
Enter no of Number not found
elements: 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 duplicate elements
elements in an array. stored 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
of integers. elements: 1 2 3 5 6

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 2 4 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 Enter how many The Numbers in
order. numbers: 7 ascending order are
Enter the 7 2445678
Numbers:
7645248

Set-2
Set-2 The Numbers in
Enter how many ascending order:
numbers :10 12 34 34 56 56 56
Enter the 10 78 90 122 799
Numbers:
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 found in the array
stored 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 Enter number of Even numbers in the
and odd numbers in an 1-D elements in the array are: 12 98
array. 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 Elements in reverse
array: 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 2 and 4
subarray that adds to a elements: 1 4 20 3
given sum. 10 5
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 15
peak element is an element elements:
that is greater than its 8 9 10 12 15
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
element in the array. A elements: (Explanation:
majority element in an array 31332 Since, 3 is present
A of size N is an element more than N/2
that appears more than N/2 times, so it is the
times 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 Value of matrix a
A 111
111111111 111
Enter value of matrix 111
B
222222222 Value of matrix b
222
222
222
After Multiplication
resultant matrix is
666
666
666

Set-2
Value of matrix a
Set-2: 222
Enter value of matrix 222
a 222
222222222 Value of matrix b
Enter value of matrix 333
b 333
333333333 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 Set 1: Set 1:
a 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
matrix. Enter no. of cols: 3 The given matrix is

Enter values to the 1 2 3


matrix: 4 5 6
Enter a [0][0] value: 1 7 8 9
Enter a [0][1] value: 2
Enter a [0][2] value: 3
Enter a [1][0] value: 4
Enter a[1][1] value: 5 The frequency of
Enter a[1][2] value: 6 occurrence of odd
Enter a[2][0] value: 7 number = 5
Enter a[2][1] value: 8
Enter a[2][2] value: 9 The frequency of
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
(sum of the diagonal square matrix A: 3 values=15
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:
Enter a number: Set 1:
WAP to find the factorial of
5 Factorial of 5 = 120
a number n by using a
2.
suitable user defined
Set 2: Set 2:
function.
Enter a number: Factorial of 0 = 1
0
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
Fibonacci number: 1
found by adding the
3. preceding two terms in the
sequence (Fi = Fi-1 + Fi-2).
Set 2: Set 2:
WAP to find out the value
Enter Fibonacci Fibonacci term serial
of nth term of the Fibonacci
term serial number: 8
sequence by writing a
number: 8 Fibonacci number: 13
suitable user 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:
Before Swapping
num1=10
Set 1:
num2=20
Enter num1: 10
Enter num2: 20
After Swapping
num1=20
Write a C program to num2=10
perform swapping of two
5
integers using a function Set 2:
SWAP. Before Swapping
num1=15
Set 2:
num2=30
Enter num1: 15
Enter 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 Enter the number Entered number: 10
through the keyboard is to test whether it Number is in Fibonacci
a number in theis in Fibonacci sequence: No
Fibonacci sequence or sequence or not:
not. (Using function) 10
1.
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
calculate the sum of the 589 single digit) of 589 = 4
2. digits of any given Set 2:
integer until it becomes Set 2: Sum of the digits (up to
a single digit number Enter a number: single digit) of 25 = 7
using function. 25
WAP to print all prime Prime numbers between 1
numbers between 1 to to 100:
100 using function. 2, 3, 5, 7, 11, 13, 17, 19, 23,
3
29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83,
89, 97
Write a function that Set 1:
Set 1:
will return the counting No of zeros: 2
Input: 110560
of 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
palindrome number or test for Number is not palindrome.
not. palindrome: 123
5.
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
array: 5
the given array: 23
Enter the elements
WAP to design a user of the array: 3 5 7 2
defined function to 6
1. calculate the sum of the
Set 2:
elements of an integer Set 2:
Sum of the elements of
1-D array. Enter the size of the
the given array: 3
array: 3
Enter the elements
of the array: 5 0 -2

Set 1:
Enter the size of the Set 1:
array: 5 Before sorting elements of
Enter the elements the given array: 3 5 7 2 6
WAP to sort the
of the array: 3 5 7 2 After sorting elements of
elements of an 1-D
6 the given array: 2 3 5 6 7
array in ascending order
2. Set 2:
by using a suitable user
Set 2: Before sorting elements of
defined function for sort
Enter the size of the the given array: 5 0 -2
operation.
array: 3 After sorting elements of
Enter the elements the given array: -2 0 5
of the array: 5 0 -2

Set 1:
Set 1:
Enter the size of the
Largest element of array is
array: 5
7
Write a C program to Enter the elements
Smallest element of array
determine the largest of the array: 3 5 7 2
is 2
and smallest element of 6
3. a 1-D array. Use
Set 2:
functions LARGEST and Set 2:
Largest element of array is
SMALLEST for the given Enter the size of the
5
purpose. array: 3
Smallest element of array
Enter the elements
is -2
of the array: 5 0 -2

4. Write a C program to Set 1: Set 1:


determine the second Enter the size of the Second largest element of
largest element of a 1-D array: 5 array is 6
array of using a function Enter the elements
SECLARGEST. of the array: 3 5 7 2
6 Set 2:
Second largest element of
Set 2: array is 0
Enter the size of the
array: 3
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
Array after swapping: 6 5
Write a C program to of the array: 3 5 7 2
723
swap the first and last 6
5. element of a 1-D array
of using a function Set 2:
Set 2:
SWAP. Enter the size of the
Entered array: 5 0 -2
array: 3
Array after swapping: -2 0
Enter the elements
5
of the array: 5 0 -2

Home Assignments (Practice Problems)

Q# Experiment Details Input Output


Write a C program to
Set 1:
swap the largest and Set 1:
Enter the size of the
smallest element of a Entered array: 3 5 7 2 6
array: 5
1-D array of using a Array after swapping: 3 5 2
Enter the elements of
function SWAP. 76
the array: 3 5 7 2 6
1. Set 2:
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

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
ODDSUM. of the array: 3 5 7 2
6
2.
Set 2:
Enter the size of the
array: 3
Enter the elements
of the array: 5 0 -2

3. Write a C program to Set 1: Set 1:


find the sum of only Enter the size of the Sum of prime values =
PRIME values in a 1-D array: 5 15
array using a function Enter the elements of Set 2:
PRIMESUM. the array: 3 5 7 2 6 Sum of prime values = 5
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
Set 1:
Enter the matrix:
Sum of the elements
4 5 6 2
of the given array:
1 9 3 0
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:
Enter the matrix:
38
5 6 2
4 3 0
-7 1 8
4 4 5
0 3 0
Set 1: Set 1:
Enter a 3x3 size matrix: Sum of the main
Write a C program to 1 2 3 diagonal elements of
determine the sum of 4 5 6 the given array: 15
main diagonal elements 7 8 9
2.
of a 2-D array of size Set 2: Set 2:
3x3 using a function Enter a 3x3 size matrix: Sum of the elements
SUMDIAGONAL. 111 of the given array: 6
222
333
3. Write a C program to Set 1:
determine the largest Enter the row and Set 1:
column size of the
matrix: 3 4
Enter the matrix:
Largest element of
4 5 6 2
array is 9
1 9 3 0
Smallest element of
7 -2 1 8
array is -2
and smallest element of
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 5 6 2 Sum of prime
1 9 3 0 elements = 17
Write a C program to
7 -2 1 8
find the sum of only
PRIME values in a 2-D
4. Set 2:
array 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
5. Write a C program to Set 1:
perform addition of two Enter matrix1: Set 1:
matrices and display 1 2 3 Result matrix
the result using 3rd 4 5 6 234
matrix. 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:
111
8 -7 10
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 matrix: 3 4
array. Use a function Enter the matrix:
SUMLS 4 5 6 2 Set 1:
1 9 3 0 Sum of largest and
7 -2 1 8 smallest elements: 7

1. Set 2:
Enter the row and Set 2:
column size of the Sum of largest and
matrix: 5 3 smallest elements: 1
Enter the matrix:
5 6 2
4 3 0
-7 1 8
4 4 5
0 3 0
2. 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
4 5 6 2 4562
1 9 3 0 1 -2 3 0
7 -2 1 8 7918

Set 2:
Entered matrix
Set 2: 562
Enter the row 430
and column -7 1 8
size of the 445
matrix: 5 3 030
Enter the
matrix: Matrix after swapping
5 6 2 562
4 3 0 430
-7 1 8 8 1 -7
4 4 5 445
0 3 0 030

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 5 6 2 sorting
1 9 3 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
4 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
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
573
9 -2 -1
810
573
Result matrix
810
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
1.
writing a recursive
Set 2: Set 2:
function for 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
Set 1: Set 1:
Write a recursive Input: 13478635 Sum of digits: 37
function to add the
4
digits of a positive
integer. Set 2: Set 2:
Input: 5875014 Sum of digits: 30
5 WAP to find out the Set 1: Set 1:
maximum element of Enter the size of the Entered Array: 3 5 7 2 6
an integer array by array: 5 Maximum elements of
using recursion. Enter the elements of the given array: 7
the array: 3 5 7 2 6

Set 2: Set 2:
Enter the size of the Entered Array: 5 0 -2
array: 3 Maximum elements of
Enter the elements of the 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 =
2105 4
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
the total number of of characters=23, Total
characters and words words=5.
present in a string.

8. Write a program to count the Hello World H=1, e=1, l=3, o=2,
frequency of each character w=1, r=1, d=1
present in a string.

9. Write a program to replace Hello World, HeHeo Worod


all the occurrence of a character= l
particular 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
multiple occurrences of a very good boy 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 [email protected]
address. Use appropriate This email Id is valid
validation criteria, such as the Case 2: Case 2:
presence of '@' and '.' symbols. studentkiit.ac.in 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 Hello World World Hello


the order of words in a given
sentence.

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 Industrial
two 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 2
pointer. 3
zc4 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 Set-1: Set-1:
largest element stored Enter the total number Largest number is 24.20
in an array of n of elements: 5
elements by using Number1: 3.4
dynamic 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 of Enter 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
elements. Change the Enter the new size of array are: 1, 2, 3, 4, 5,
size of the array, get the array: 10
the new elements and Enter new elements of Enter the new size of
print the array. Finally the array: 6 7 8 9 10 the 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 Set-1: Set-1:
numbers in cyclic order Enter a, b and c Value before
using Call by Reference. In respectively: 1 swapping:
other words, WAP that 2 a=1
takes three variables (a, b, 3 b=2
c) as separate parameters c=3
and rotates the values Value after swapping:
stored so that value a goes a=3
to b, b to c 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 -
pointers. value of a: 10 value of a: 20

Set-2: Set-2:
Before changing - After changing -
value of a: 50 value of a: 60

3 WAP to count distinct Enter the string: Java Consonants are:


number of vowels and 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
been successfully allocated calloc.
by calloc or not. Calloc Memory
Finally Free the memory. successfully freed.

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 Input Output
Details
1. WAP to store one Enter the students’ data: The student’s details are:
student’s Roll Number: 1505201 Roll Number: 1505201
information (i.e. Name: Rajesh Agarwal Name: Rajesh Agarwal
student’s roll no, Gender: M Gender: M
name, gender, Marks: 95 Marks: 95
marks etc) of an
educational institute
and display all the
data, using structure

2. WAP to store n Set 1: Set 1:


students’ Enter the number of The students details are
information (i.e. students: 1 Roll Number: 1505201
student’s roll no, Enter the students’ data: Name: Rajesh Agarwal
name, gender, Roll Number: 1505201 Gender:M
marks in 5 subjects Name: Rajesh Agarwal Mark in subject 1: 95
etc) of an Gender: M Mark in subject 2: 85
educational institute Mark in subject 1: 95 Mark in subject 3: 75
and display all the Mark in subject 2: 85 Mark in subject 4: 65
data with total Mark in subject 3: 35 Mark in subject 5: 55
marks of each Mark in subject 4: 65 Total marks: 375
student, using Mark in subject 5: 55 List of fail students: 1
array of structure. If
full mark of each Enter subject number
subject is considered whose failed list to be
as 100 and pass displayed: 3
mark as 40, then
display the list of Set 2: Set 2:
students failed in a Enter the number of The students’ details are
particular subject. 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
structures. Enter km: 6 km 100 m
Enter meter: 600

Enter data for 2nd


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 Next year is : 24-03-2024
functions for the date add: 9 After addition of days :
manipulations. No. of months to 2-04-2023
a) To increment date by 1 add: 2 After addition of months :
day No. of years to 24-05-2023
b) To increment date by 1 add : 3 After addition of years :
month 24-03-2026
c) To increment date by Month name : March
1year Date : 24.03.23
d) to add few days in a date.
e) To add few months in a
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 Character: A
having three one: Integer: 42
members a, b and c Enter a character: A Double: 3.140000
as character, integer Enter an integer: 42
and double Enter a double: 3.14
respectively. Assign Set-2
user entered values Set-2 Values entered all
to these members Enter a character, an together:
respectively one by integer, and a double all character: @
one and display together: integer: 10586
these values A double: 3.14
immediately. Again, 42
assign these user 3.14
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
division operations First real = 7 no. As = 3.0 + 6.0 i
on 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 Enter Category: Clerk
the new salary details: Enter Address: Patia
structure after C. Increment the salary: A Square, Kalarahanga
increment. Given Enter Basic Salary:
basic: Rs 12500, DA: What do you want to do? 12500
50%, and HRA 10%. A. Enter new employee
details:
B. Search employee Enter First Name: Arjun
details:
C. Increment the salary: B Name: Arjun Mohanty
Address: Patia Square,
What do you want to do? Kalarahanga
A. Enter new employee Gross Salary: 20000
details:
B. Search employee Enter First Name: Arjun
details: Percentage Increase: 10
C. Increment the salary: C
Enter First Name: Arjun
What do you want to do?
A. Enter new employee Name: Arjun Mohanty
details: Address: Patia Square,
B. Search employee Kalarahanga
details: Gross Salary: 22000
C. Increment the salary: B

Home Assignments (Practice Problems)

Q# Experiment Details Input Output


1 WAP to calculate the Set-1 Set-1
difference between two Enter Choice :
time periods. Times are 1. 12 hr format Difference between
given in (hr:min:sec) User 2. 24 hr format Time 1 and Time 2
has to choose whether 12hr 1 is-
or 24 hr format. Enter time1- 3 hrs 15 mins 20
09:25:30 secs
Enter time 2-
06:10:10

Set-2
Enter Choice:
1. 12 hr format Set-2
2. 24 hr format
2 Difference between
Enter time1- Time 1 and Time 2
14:20:10 is-
Enter time2- 1 hrs 10 mins 5 secs
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 test.txt From the small
the content of a file From the small beginnings KIIT has
test.txt beginnings KIIT has developed into a leading
developed into a university
leading university
2 WAP to write the text Content of test.txt
From the small From the small
beginnings KIIT has beginnings KIIT has
developed into a developed into a leading
leading university into a university
file test.txt
3 WAP to append the Content of test.txt Content of test.txt
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” leading university university with a strong
into the file test.txt interdisciplinary culture
and a commitment to
teaching excellence
4 WAP to count the total Content of test.txt 150
number of characters in From the small
the file test.txt 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 test.txt 22
number of words in the From the small
file test.txt 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 test.txt Content of test.txt
letters in the file test.txt 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 test.txt Content of new.txt
the file test.txt to FROM THE SMALL FROM THE SMALL
another file new.txt 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 Same as previous Same as previous
1-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 test.txt Content of test.txt
factorial of number 5 5
given as input 120
through a file test.txt
and append the
factorial value in the
file.
2 WAP to count the Content of test.txt
case-insensitive From the small beginnings KIIT
occurrences of a has developed into a leading
given word in a file university with a strong
test.txt 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 test.txt Paragraph -1 words
each paragraph in a From the small beginnings KIIT – 22
file test.txt 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 test.txt Paragraph -1 words
From the small beginnings – 22
KIIT has developed into a Paragraph -2 words
leading university with a - 12
strong 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 testdate.txt YES
mm-yyyy format in a Today date is 01-01-2023
file testdate.txt
Set 2 Set 2
Content of testdate.txt NO
Today date is 1st January of
2023
6 WAP to check if a Set 1 Set 1
filepath, given as the test1.txt Filepath doesnot
commandline exist
argument, exists in
the system Set 2 Set 2
test.txt Filepath exists
7 WAP to delete a file if Set 1 Set 1
that exists in the test1.txt Filepath doesnot
system, where the exist
filepath is given as
the commandline Set 2 Set 2
argument test.txt 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
No Component Marks
.

Continuous Evaluation 15
Pre-Mid
Lab Report + Attendance
Sem
Internal Viva/Quiz/Programming Test 15
1 (60
Post- Continuous Evaluation 15
Marks)
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)

 https://onlinecourses.nptel.ac.in/noc22_cs40/preview

You might also like