KEMBAR78
Programming Lab Lesson Plan 2023-v1 | PDF | Matrix (Mathematics) | Quadratic Equation
0% found this document useful (0 votes)
48 views50 pages

Programming Lab Lesson Plan 2023-v1

The document outlines the laboratory lesson plan for the Programming Laboratory course (CS13001) at KIIT University for the Autumn 2023 semester. It includes a week-wise schedule detailing topics such as computer fundamentals, programming concepts, and various C programming assignments. The plan also specifies lab assignments, home assignments, and exams throughout the semester.

Uploaded by

Adyasha Mohanty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views50 pages

Programming Lab Lesson Plan 2023-v1

The document outlines the laboratory lesson plan for the Programming Laboratory course (CS13001) at KIIT University for the Autumn 2023 semester. It includes a week-wise schedule detailing topics such as computer fundamentals, programming concepts, and various C programming assignments. The plan also specifies lab assignments, home assignments, and exams throughout the semester.

Uploaded by

Adyasha Mohanty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

School of Computer Engineering

KIIT deemed to be University


Laboratory Lesson Plan – Autumn’2023 (3rd Semester)

Discipline: Information Technology


Course name and Code: PROGRAMMING LABORATORY ( CS13001)
(L-T-P-Cr: 0-2-4-4 )
Instructor Name: JHALAK HOTA
Instructor Chamber: FB-201 Campus 14 KIIT University
Sr # Details Week#
1 Fundamentals of computer, Number systems and basic Linux 1
commands.
2 Practice and write programs on simple input and output operations. 2
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
7 Practice and write programs on Functions. 8,9
8 More practice problems, tests 10
9 Mid Sem Exam (16th to 21st October) 11
10 Practice and write programs on Character Arrays 12
11 Practice and write programs on Pointers 13, 14
12 Practice and write programs on Structures and Unions 14, 15
13 Practice simple programs on file handling 16
14 Sessional Exam (4th to 9th December) 17
Technical Assistants Names:

1. Mrs Manorama Chaudhury


2. Mr. Jasobanta Swain
Course Contents : Week-wise lesson plan
List of Experiments (Day wise):

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


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. Enter 2nd number:13 Sum is 25.
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 The area is: 380.12
3. a circle while taking circle: 11
radius as user input.
WAP to calculate area of Enter the height of the
4 a triangle who’s base triangle: 12 The area of the
and height are user Enter the base of the triangle is: 60.
input. triangle: 10
Write a C program to Before Swapping
5 perform swapping of two Enter num1: 10 num1=10, num2=20
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
2. mark of each subject is
200. All the input must
Enter the number of 3rd
subject: 165
be given by user. Enter the number of 4th
subject: 180
Enter the number of 5th
subject: 185
3 WAP to convert given Enter the amount:550 550 paisa = 5 Rupee and
paisa into its equivalent paisa. 50 paisa
rupee and paisa as per
the following format.

Day 04 : Lab Assignments


Q# Experiment Details Input Output
WAP to convert given second
1. into its equivalent hour, Enter the time:7560 7560
27
second = 2 Hour,
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: Sum of digits is: 11.
3. and last of a six-digit number. 234459
Number must be a user input.
WAP to find the sum of all Enter the number:
4. digits of a three-digit number. 354 Sum of digits is: 12.
Number must be a user input.
Set 1:
Enter the buying
The mark price and discount price: 80
and buying price are entered Enter the marker
through keyboard. Sometimes price: 100. Set 1:
seller gets profit or some time Enter the discount: Seller made a loss of
5. loss depends on discount. 25% 6.25%.
WAP to determine whether the Set 2:
seller has made profit or Enter the buying Set 2:
incurred loss. Also determine price: 80 Seller made a profit of
how much profit he made or Enter the marker 12.50%.
loss incurred. price: 100.
Enter the discount:
25%

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 swap the contents of two Enter num1: 10 Before Swapping
variables by using a single Enter num2: 20 num1=10,num2=20
2. statement for swap in C. 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
3. entered through the keyboard [Input must be taken in
in the format hh:mm:ss such a way so that sum
should not exceed 24
hours]
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 it Enter an alphabet: B The entered character
whether it 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 Set 2:
not. Set 2: 1996 is a leap year.
Enter the year:1996
5 WAP to find the roots of a Set1 Set1
quadratic equation Input values for a, b Input values for a, b
ax2+bx+c=0 using if-else and c=>1 and c=>1
statement. 2 2
1 1
Set2 Set2
Input values for a, b The Roots are real &
and c=>1 8 3 unequal.
Roots are -0.39 and
Set 2 -7.61
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
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 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 number
Enter a number
: 100
2 Write a C program to determine Input the marks The candidate is not
eligibility for admission based on obtained in eligible for admission.
the following 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 subject >=190 or Mathematics :72
Total in Maths and Physics >=140
3 Write a C Program to check Set 1: n1=3, Set 1: isosceles
whether the triangle is equilateral n2=3, n3=4
isosceles or scalene (Triangle
consists of three sides of provided
lengths n1, n2 and n3 units).
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
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
n=123 SET 2
The sum of digits of 123
is 6
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=123 The reverse of 123 is 32`
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=4 The factors are
124
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 SET 2 SET 2
cubes of its digit is equal with the n=121 The given number is not
original number. Armstrong
Ex-153)
3 WAP to test whether a number is SET 1 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 Palindrome
when the sum of factors SET 2 SET 2
excluding the number itself is n=28 The given number is
equal to the original number. Palindrome
Ex-6)
3 WAP to check whether a Set 1: Set 1:
number n is prime number or Enter a number:17 You have entered
not. 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
Lucas sequence which is a 1 3 4 7 11 18 29 1 3 4 7 11 18 29
variation on the Fibonacci … …
sequence are:
1 3 4 7 11 18 29 …
WAP to generate the Lucas
sequence.
5 WAP to print GCD and LCM of 12 GCD of 12 and 18 is
two numbers. 18 6
LCM of 12 and 18 is
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 inputted SET 1 SET 1
number is a strong number or n=145 The given number is
not. Strong
(A number is said to be Strong if SET 2 SET 2
sum of factorial of digits is n=121 The given number is
equal to the original number) 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
6
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 Enter the The value is 4.0
n terms. value of x and
n:
22

Day 9
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 2 2 2 2
1111 3333
2222 4444
3333
4444
4. WAP to print the following pattern Enter Row 1
1 Number : 5 1 2
12 123
123 1234
1234 12345
12345
5. WAP to print the following pattern 1
1 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 *****
******* ***
***** *
***
*
21 WAP to print the Enter the value of 1
following pattern n: 21
1 5 123
21 4321
123 12345
4321
12345
Day 11 : 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 Set 1:
an 1-d array. Enter no of elements : The resultant array:
5
12345 162345
Enter the element to
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 Set 2:
be searched : 44 Number not found
Set 2:
Enter no of elements :
5
11 22 33 44 55
Enter the elements to
be searched : 77
2. WAP to Count the total Total number of
number of duplicate elements Input the number of duplicate elements
in an array. elements to be stored found in the array: 2
in the array :5
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 Set 1: Set 1:
multiplication of the numbers
stored in an array of integers. Enter array size: 5 Product of the array
elements = 180
Enter array elements:
12356
4. WAP to find the second Input the size of array The Second largest
largest element in an 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 array Input the position
desired position from an : 5 where to delete: 3
array. Input 5 elements in
the array in The new list is : 1 2
ascending order: 4 5
element - 0 : 1
element - 1 : 2
element - 2 : 3
element - 3 : 4
element - 4 : 5
DAY-12
TOPIC : 1D Arrays
1. WAP to display the array RUN-1 RUN-1
elements in ascending order. Enter how many The Numbers in
numbers :7 ascending order are
Enter the value of 7 2445678
Numbers:-
7645248 RUN-2
The Numbers in
RUN-2 ascending order are
Enter how many 12 34 34 56 56 56 78
numbers :10 90 122 799
Enter the value of 10
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 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 Set 1: Set 1:
odd numbers in an 1-d array. Enter number of Even numbers in the
elements in the array: array are: 12 98
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 size of the
array: 5 Reversed array is: 5 4
Enter Array 321
Elements: 1 2 3 4 5
5. Given an array arr[] of Input: Sum found between
non-negative integers and an Enter array size: 6 indexes 2 and 4
integer sum, find a Enter array elements:
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 Since, 3 is present
element in an array A of size more than N/2
N is an element that appears times, so it is the
more than N/2 times in majority element.
the array.
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},
the task is to rotate the array d = 2
elements to the left by d
positions.

DAY-13 , 14
TOPIC : 2D Arrays
Q# Experiment Details Input Output
1. WAP for a two Displaying values:
dimensional to store Enter no of City : 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 value 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 Matrix:
2*2 using Enter a11: 2; 2.2 0.5
multidimensional Enter a12: 0.5;
arrays. Enter a21: -1.1; -0.9 25.0
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 RUN-1: RUN-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
RUN-2: 222
Enter value of matrix a 2 2 2
222222222 After Multiplication
Enter value of matrix b resultant matrix is
333333333 666
666
666
RUN-2
Value of matrix a
222
222
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 upper Enter no. of rows : 3
triangular. 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 not equal to
Matrix B
Enter values to the
matrix B :
Enter a[0][0] value : 1
Enter a[0][1] value : 2
Enter a[0][2] value : 3
Enter a[1][0] value : 4
Enter a[1][1] value : 5
Enter a[1][2] value : 6
Enter a[2][0] value : 7
Enter a[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 Set 2:
Enter a[1][0] value : 0
Enter a[1][1] value : 1 The given matrix is not an
Enter a[1][2] value : 0 Identity Matrix.
Enter a[2][0] value : 0
Enter a[2][1] value : 0 1 2 3
Enter a[2][2] value : 1 0 1 0
0 2 1
Set 2:
Enter no. of rows : 3
Enter no. of cols : 3
Enter values to the
matrix :
Enter a[0][0] value : 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 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 Enter the order of the sum of diagonal values=15
Trace(sum of the square matrix A :- 3
diagonal element) of a Enter the values of
given mxn matrix matrix A
345
689
134
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
WAP to find the factorial of a Set 1:
Enter a number: 5
Set 1:
Factorial of 5 = 120
2. number n by using a
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
3. by adding the preceding two
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 7
an integer: Set 1:
7 is prime.
4 determine a number is
prime or not using a Set 2: Set 2:
function named as “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
num2=20
5 perform swapping of two
integers using a function After Swapping
SWAP. 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 to
numbers between 1 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 Input: 110560 No of zeros: 2
Zeros in a Positive
4. Integer
Set 2: Set 2:
Input: 178655 No of zeros: 0
Set 1: Set 1:
WAP to test whether a Enter a number to Entered number: 123
5. number n is test for Number is not palindrome.
palindrome number or palindrome: 123
not. Set 2:
Enter a number to test for
Set 2: palindrome: 1551
Enter a number to Number is palindrome.
test for
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
WAP to design a user Enter
the
the elements of
array: 35726
defined function to
1. calculate the sum of the Set 2:
elements of an integer Enter the size of the SetSum
2:
of the elements of the
1-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
2. ascending order by using 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
Write a C program to Enter the elements of Second
array is
largest element of
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:
SECLARGEST. Enter the size of the Set 2:
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 2 3
5. swap the first and last
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
Set 1:
Write a C program to Enter the size of the Set 1:
swap the largest and array: 5 Entered array: 3 5 7 2 6
smallest element of a Enter the elements of Array after swapping: 3 5 2
1-D array of using a the array: 3 5 7 2 6 76
1. function SWAP. 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: -1 0 5
Set 1:
Write a C program to Set 1: Sum of prime values = 15
find the sum of only Enter the size of the Set 2:
odd values in a 1-D array: 5 Sum of prime values = 5
2. array using a function Enter the elements of
ODDSUM. 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

Set 1:
Write a C program to Enter the size of the Set 1:
find the sum of only array: 5 Sum of odd values = 15
PRIME values in a 1-D Enter the elements of Set 2:
3. array using a function the array: 3 5 7 2 6 Sum of prime values = 5
PRIMESUM. 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 5 6 2 Sum of the elements
1 9 3 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 Set 2:
SUMDIAGONAL. Set 2: Sum of the elements
Enter a 3x3 size matrix: of the given array: 6
111
222
333
Set 1:
Enter the row and
column size of the
matrix: 3 4 Set 1:
Enter the matrix: Largest element of
4 5 6 2 array is 9
Write a C program to 1 9 3 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 5 6 2 Sum of prime
Write a C program to find 17 -29 31 08 elements = 17
the sum of only PRIME
4. values in a 2-D array 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
Set 1:
Write a C program to Enter matrix1: Set 1:
5. perform addition of two 1 2 3 Result matrix
matrices and display the 4 5 6 234
result using 3rd matrix. 7 8 9 678
Enter matrix2: 10 11 12
111
222
333
Set 2:
Enter matrix1: Set 2:
123 Result matrix
-4 5 -6 234
7 -8 9 365
Enter matrix2: 8 7 10
111
111
111

Home Assignments (Practice Problems)


Q# Experiment Details Input Output
Set 1:
Write a C program to Enter the row and
determine the sum of column size of the
largest and smallest matrix: 3 4
element of a 2-D array. Enter the matrix:
4 5 6 2 Set 1:
1 9 3 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
Set 1:
Write a C program to Entered matrix
swap the largest and Set 1: 4562
smallest element of a Enter the row 17 9-23108
2-D array of using a and column
function SWAP. size of the Matrix after swapping
2. matrix: 3 4
Enter the 41 5-26320
matrix: 7918
4 5 6 2
1 9 3 0 Set 2:
7 -2 1 8 Entered matrix
562
430
Set 2: -7 1 8
Enter the row 445
and column 030
size of the
matrix: 5 3 Matrix after swapping
Enter the 562
matrix: 430
5 6 2 8 1 -7
4 3 0 445
-7 1 8 030
4 4 5
0 3 0

Write a C program to Set 1:


sort the elements of a Enter the row Set 1:
values in a 2-D array and column size Entered matrix
using a function of the matrix: 3 4562
SORTELE. 4 1930
Enter the 7 -2 1 8
matrix:
4 5 6 2 Matrix after 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 sorting
4 4 5 -7 0 0
0 3 0 012
334
445
568

Write a C program to Set 1: Set 1:


4 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
Set 2: Result matrix
Enter matrix1: 11 18 9
231 16 28 14
741 8 24 12
9 -2 1 Set 2:
Enter matrix2: Enter matrix1:
9 -2 -1 231
573 741
810 9 -2 1
Enter matrix2:
9 -2 -1
573
810
Result matrix
41 18 7
91 15 5
79 -31 -15

Day 18
Recursion

Lab Assignments
Q# Experiment Details Input Output
WAP to find the factorial Set 1: Set 1:
of a number n by writing Enter a number: 4 Factorial of 4 = 24
1. a recursive function for
it. Set 2: Set 2:
Enter a number: 1 Factorial of 1 = 1
Set 1: Set 1:
WAP to calculate Enter
105
two numbers:
60 GCD of 105 and 60 = 15
2. GCD/HCF of two
numbers by using a Set 2:
recursive function. Enter two numbers: Set 2:
5 70 GCD of 5 and 70 = 5
WAP by designing a Set 1: Set 1:
recursive function to Enter a number: 589 Sum of the digits (up to
3. calculate the sum of the single digit) of 589 = 4
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 count the Input: 13478635 Sum of digits: 37
4 digits of a positive
integer (do also for sumSet 2: Set 2:
of digits) 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
WAP to find out the Enterthe
the elements of
array: 35726
given array: 7
5 maximum element of an
integer array by using Set 2:
recursion. Set 2:
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
of digits of a positive Set 1: Set 1:
integer n by using a Enter a number: Number of digits of 10 = 2
1. recursive function. 10 Set 2:
Set 2: Number of digits of 2105 = 4
Enter a number:
2105
WAP to find the nth
Fibonacci number Set 1: Set 1:
using recursion. Enter the value of n = 10
n: 10 nth Fibonacci number =
2. 34
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
3 null terminated string
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:
4. array to another Please Enter the
Array Elements : 3 Value Inside Array b[0] = 3
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
Set 1: Set 1:
Write a recursive Input: 765 Output: 1011111101
5. function to convert a
decimal number to
binary
Lab Assignments
Q# Experiment Details Input Output
1. WAP to find the length of a Programming Length of the entered
string with/without using String is 11
library function for getting
length of the string
2. Write a program to extract How are You weu
last character of every word
present in a sentence.
3. Write a program to 1: KIIT String KIIT University
concatenate two strings 2: University
without using any library
function.
4. Write a program to Set1: Kalinga Set1: Not Palindrom
check whether an
entered string is Set2 : Set2: Palindrome
palindrome or not. Madam
5. Write a C program to Industrial dust
extract a substring 24
from a given string.
Prompt the user to
enter the starting
position and length of
the substring.
6. Write a C program to You are very very
find the largest word in good boy.
a given sentence.
Assume that words are
separated by spaces.

7. Write a program to This is the Vowels=3 ,


count the number of best consonants=9 ,
vowels, consonants, university. new lines=1 ,
new lines and the total total number of
number of characters characters=23 ,
and words present in a Total words=5.
string.
8. Write a program to Hello World H=1, e=1, l=3, o=2, w=1,
count the frequency of r=1, d=1
each character present
in a string.
9. Write a program to Hello HeHeo Worod
replace all the World,
occurrence of a character
particular character in =l
a string by it’s previous
3rd character, If any.

10. Write a C program to Hello world Hello world


remove all leading and
trailing spaces from a
given string, if any.
11. Write a C program to You are a You a very good
replace multiple very very boy
occurrences of a good boy
specific word present
in a given sentence.

Home Assignments (Practice Problems)


Q# Experiment Details Input Output
1 Write a C program to Kalinga Kalinga Institute Of
capitalize the first letter of institute of Industrial Technology
each word in a given industrial
sentence. Assume that technology
words are separated by
spaces.
2 Write a C program to Case 1: Case 1:
check if a given string is a student@kiit.
valid email address. Use ac.in This maild is is valid
appropriate validation Case 2: Case 2:
This maild is is not
criteria, such as the studentkiit.a valid
presence of '@' and '.' c.in
symbols.
3 Write a C program to worth throw
check if two strings are
anagrams. An anagram is
a word or phrase formed
by rearranging the letters
of another word or phrase.
4 Write a C program to College Coleg
remove all duplicate
characters from a given
string. The resulting
string should contain each
character only once.
5 Write a C program to Hello World World Hello
reverse the order of words
in a given sentence.
6. Write a C program to aaabbbcccdd abcde
remove all consecutive deee
duplicate characters from
a given string.
7. Write a C program to find Institute Instu
the common characters Industrial
between two strings.
Display the common
characters in alphabetical
order.
8. Write a C program to Case 1: kiit Case 1:0
compare two strings kiit Case 2:9
without using the built-in Case 2: kite
strcmp() function. bite
9. Write a C program to "12345" 12345
convert a string of digits
into an integer value.
10. Write a C program to Hello World Hll Wrld
remove all vowels from a
given string. Consider
both uppercase and
lowercase vowels.
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. Set 2 : TIIK
Input a string : MADAM Set 2:
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
Set 2: Number of Consonants
Input a string : string in String:7
Set 2:
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 memory Number1: 3.4
allocation. Number2: 2.4
Number3: -5
Number4: 24.20
Number5: 6.7
Set-2:
Enter the total number Set-2:
of elements: 4 Largest number is 56
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, allocated using calloc.
array, then print the 5 The elements of the array
elements. Change the are: 1, 2, 3, 4, 5,
sixe of the array, get Enter the new size of the
the new elements and array: 10 Enter the new size of the
print the array. Finally Enter new elements of array: 10
free the memory. the array : 6, 7, 8, 9, 10, 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 2 a=1
takes three variable (a, b, c) 3 b=2
in as separate parameters Set-2: c=3
and rotates the values Enter a, b and c Value after swapping:
stored so that respectively: 5 a=3
value a goes to be, b, to c 6 b=1
and c to a. 7 c=2
Set-2:
Value before
swapping:
a=5
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 Set-1: Set-1:
number of vowels and Enter the string: Consonants are:
consonants present in a Java J-1
string using pointer. v-1
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.
Day 28 : Lab Assignments
Q# Experiment Details Input Output
1. WAP to store one Enter the students data: The students 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:
student’s information
(i.e. student’s roll no, Enter the number of The students details are
name, gender, marks student : 1 Roll Number: 1505201
in 5 subjects Enter the students data: Name: Rajesh Agarwal
etc) of an educational Roll Number: 1505201 Gender:M
institute and display Name: Rajesh Agarwal Mark in subject 1: 95
all the data with total Gender:M Mark in subject 2: 85
marks of each Mark in subject 1: 95 Mark in subject 3: 75
student, using Mark in subject 2: 85 Mark in subject 4: 65
array of structure. If Mark in subject 3: 35 Mark in subject 5: 55
full mark of each Mark in subject 4: 65 Total marks : 375
subject is considered Mark in subject 5: 55 List of fail students : 1
as 100 and pass
mark as 40, then Enter subject number
display the list of whose fail list to be
students failed in a displayed : 3
particular subject.
Set 2 : Set 2:
Enter the number of The students details are
student : 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 fail list to be
displayed : 4
3. WAP to add two Set-1 Set-1
distances (in Enter data for 1st
km-meter) using distance : Sum of distances = 14
structures. Enter km: 6 km 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
distance : km 200 m
Enter km: 7
Enter meter: 700
Enter data for 2nd
distance
Enter km: 8
Enter meter: 500
4. WAP to add two times Set-1 Set-1
(in hr-min-sec) by Enter Time 1 -> 3 : 40 :
passing structure to 50 Sum of time is -> 6 : 26
a function. Enter Time 2 -> 2 : 45 : : 40
50
Set-2 Set-2
Enter Time 1 -> 5 : 10 :
45 Sum of time is -> 11 :
Enter Time 2 -> 6 : 40 : 51 : 30
45
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
employees 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 : Next day is : 25-03-2023
and typedef. Write the 24-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 : 29
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
user entered values to Enter a character, an Set-2
these members integer, and a double all Values entered all
respectively one by together: together:
one A character: @
and display these 42 integer: 10586
values immediately. 3.14 double: 3.14
Again assign these
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 time2-
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
Lab Assignments
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 leading developed into a leading
university into a file university
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 into leading university university with a strong
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 Set 1
case-insensitive From the small beginnings KIIT 3
occurrences of a given has developed into a leading
word in a file test.txt university with a strong Set 2
interdisciplinary culture and a 1
commitment to teaching
excellence
Set 1
Input the word to search: a
Set 2
Input the word to search: THE
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 Set 2
commitment to teaching Paragraph -1 words
excellence – 22
Paragraph -2 words
- 12
4 Check if contents of Set 2
two files are same Content of test.txt
From the small beginnings
KIIT has developed into a
leading university with a 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 Content of testdate.txt YES
dd-mm-yyyy format in Today date is 01-01-2023
a file testdate.txt
Set 1 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 Set 2
the system test.txt Set 2
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 Set 2
commandline test.txt Set 2
argument Fie deleted
successfully
Grading Policies:
Internal/Sessional Assessment Weightage /
S Component Marks
No.
1 Internal (Sample) Lab Report + Attendance 20
(60 Marks) Viva 10
Quiz 10
Programming Test 10
Continuous Evaluation 10
2 Sessional Quiz 20
(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