Department of Computer Science and Engineering
NITK, Surathkal
Course Plan and Evaluation Scheme
(B. Tech 2nd Semester, 2018-19)
1. Course code: CS111
2. Course Title: Computer Programming Lab
3. L-T-P: (0-0-2)
4. Credits: 1
5. Semester: B. Tech 2nd Semester
6. Academic Year: 2018-19
5. Course Instructors:
S1: Aishwary
S2: Y. V. Srinivas
S3: Vidya Maygeri
S4: Girish
S5: Marwa
S6: Rakshitha Kotian
6. Teaching Department: Computer Science & Engineering
7. Objective of the Course:
● Learning to code and debug C programs in a UNIX environment.
● Implement programming strategies to understand various C language
concepts.
8. Skill development expected from the course:
● Develop efficient and modular C code.
● Develop programming skills, logical thinking and reasoning for problem
solution.
9. Course Coverage:
Topics Lab Hours
UNIX shell commands 3
Execution and debugging 3
Basic Input-Output functions 3
Operators and Expressions 3
Decision making and Branching constructs 3
Decision making and looping constructs 3
Page 1 of 7
Arrays 3
Strings 3
Functions and Recursions 6
Structures and Union 3
Pointers 3
Files and file operations 3
Total 39
10. Course Contents
B1. Unix shell commands SSH Shell
Introduction to basic commands on SSH shell
B2. Basic Input-Output functions
1. To find Simple and Compound Interest
2. To read the radius of a circle and find its Area and Perimeter.
3. To read the temperature in Fahrenheit and convert it to degree centigrade.
4. Program to accept student roll no, marks in 3 subjects and calculate total,
average of marks and print them with appropriate messages.
5. An Employee's Basic Pay (BP) is to be read through keyboard. DA is 40% of
BP, HRA is 20% of BP, calculate the Gross Pay (GP) GP is computed as
BP+DA+HRA.
6. Program to find the distance between two points (x1, y1) and (x2, y2) in a
Cartesian plane.
7. Program to swap two numbers using a temporary variable. Also print the
original and exchanged values.
B3. Operators and Expressions
(Program to illustrate the use of Arithmetic, Relational, Logical, Assignment,
Conditional, Increment or Decrement, Bitwise, Special operators their associativity
and precedence.)
1. The distance between two cities (in km.) is input through the keyboard. Write
a program to convert and print this distance in meters, feet, inches and
centimeters.
2. The length & breadth of a rectangle and radius of a circle are input through
the keyboard. Write a program to calculate the area & perimeter of the
rectangle, and the area & circumference of the circle.
Page 2 of 7
3. If a five-digit number is input through the keyboard, write a program to
calculate the sum of its digits.
4. If a five-digit number is input through the keyboard, write a program to reverse
the number.
5. If the total selling price of 15 items and the total profit earned on them is input
through the keyboard, write a program to find the cost price of one item.
6. Write a program to compute the values of square-roots and squares of the
numbers 0 to 100 in steps 10.
B4. Decision making- and Branching constructs
1. To determine whether character entered is in lowercase, uppercase, digit or a
special character.
2. Find the roots of quadratic equation
3. Given 3 sides, write a program to check whether the triangle can be formed
for the following conditions.
No triangle if a>= b+c
Right Angled triangle if a2=b2+c2
Obtuse triangle if a2>b2+c2
Acute triangle if a2<b2 +c2
Equilateral triangle if all sides of the triangle are same
Isosceles triangle if two sides of the triangle are same
Scalene triangle otherwise
Implement using switch-case, if and else-if ladder:
4. Write a menu driven program to demonstrate the simple arithmetic calculator
5. Program to display the grade obtained by a student based on the marks. The
relation between the grades and marks is –
Marks Grades
Below 40 Fail
40-59 E
50-59 D
60-69 C
70-79 B
80-89 A
90-100 A+
Page 3 of 7
B5. Decision making and looping constructs
1. Program to reverse the digits of a number and to find the sum of the digits.
2. Program to find factors of a given number.
3. Program to find the prime and non prime numbers between a given range.
4. Program to print numeric pyramid (Defined by the instructor).
5. Program to find GCD and LCM of two given numbers.
6. Program to evaluate 1+x2 /2! + x3/3! +…….+xn /n!
B6. Arrays
1. To read an array of N elements and reverse it.
2. Program to count the number of palindromes in a given list of n numbers
3. Find the pair of numbers in an unsorted array such that their sum is the
largest
4. Program to insert an element in a specified position in a given array.
5. To search for a key in an array using i)Linear search ii)Binary search
6. To sort array elements in ascending order using i) Bubble sort ii) Selection
sort.
7. To add and multiply two matrices.
8. To interchange principal and secondary diagonal elements in a matrix.
B7. Strings
1. To read a string and find its length without using library function.
2. To reverse a string and check whether the string is palindrome or not.
3. To delete extra blank spaces in a string
4. Program to replace lowercase characters by uppercase & vice-versa
5. Program to delete all occurrences of a substring in a given line of text.
6. C Program to find all consecutive occurrences of any vowel in a string
B8. Functions
1. Write a function to generate n Fibonacci numbers.
2. Program to implement the following string functions (use switch-case to make
the program menu driven)
i. Find length of a string.
ii. Copy a string to the other.
iii. Compare two strings.
3.
Program to evaluate the equation y=x1+ x2 + x3 +……….xn
Page 4 of 7
4. To add numbers using function.
5. Program to calculate the value of n pr.
6. Program to find whether an entered year is a leap year or not.
B9. Recursion
1. To find factorial of a number
2. To generate Fibonacci series up to a given number.
3. To search for a number using binary search method
4. To find sum of series 1+1/3!+1/5! + …… +1/N!
5. Program to reverse a string.
6. Program to find the biggest number in an array.
B10. Structures and Union
1. Program to input and display book information ( Title of the book, Author ,
ISBN, Price)
2. Program to accept 5 people’s name, address and telephone number and to
search for the information of a particular person.
i. Based on name
ii. Based on telephone number
3. Accept a name, register number, marks in 6 subjects of N students. Find
total and average of each student. Sort this array of structures
i. Based on name.
ii. Based on register number.
iii. Accept a register number and search for this student using binary
search
iv. Find the average marks for each student and sort them in
ascending order of average marks.
v. Display the details of a student given his register number
4. Store the item number, item name, unit price and quantity in stock of N
items in a supermarket. Display the following list of items present in the
stock.
i. List of items with unit price greater than Rs 129.
ii. List of items with quantity in stock less than 5.
5. Write a menu driven program for the following
i. Add two distances (in inch-feet) using structures
ii. Add two complex numbers by passing structure to a function
Page 5 of 7
iii. Calculate the difference between two time periods using structures.
6. Write a C program to compare structure and union variables
B11. Pointers
1. Program to count frequency of every character present in a line of text.
2. Program to swap two numbers.
3. Program to find area and circumference of a circle.
4. Write functions for the following string operations.
a) Concatenation. b) Comparison. c) Length d) Copy e) Reverse.
5. Write a program to display the greatest of N numbers –use malloc() function.
6. Write a program to arrange N names in alphabetical order using dynamic
memory allocation.
B12. Files and file operations
1. Program to read data from the keyboard; write it in a file called DATA.txt.
Again read the same data from the file and display it on the screen.
2. A file named DATA.txt contains a series of integer numbers. Write a program
to read these numbers and then write all odd numbers to a file to be called
ODD and all even numbers to a file to be called EVEN.
3. Copy the content of one file into another.
4. Program to append the content of file at the end of another without using
append mode.
5. Program to find the size of file using file handling function.
6. Program to find the number of lines in a text file.
11. Evaluation Plan:
Weightage
Sl. No. Items Remarks
(%)
Two programs 15 marks
1 End-Sem 40 each and viva-voce 10
marks
Two programs 10 marks
2 Mid-Sem 25 each and viva-voce 5
marks
One program from the
given list and two surprise
3 Regular Lab Performance 15
programs for 5 marks
each
Page 6 of 7
Sum of two tests, each
4 Surprise Test 20
with the 10 marks
Note:
● Grade cutoff is common for S1-S6 section.
● Sl. No. 1-4, randomly selected questions (similar to the problems discussed in
regular tutorial classes) by the course instructors from the common pool of
questions.
● Sl. No. 3, observation book is compulsory.
● Schedule: Sl. No. 1: Week 17 and Sl. No. 2: Week 08 and Sl. No. 4: Instructor
discretion.
● Syllabus: Surprise Test-1: B1-B4, Mid-Sem: B1-B6, Surprise Test-2: B7-B10,
and End-Sem: B1-B12.
Lab Instructions (Procedure):
● Step 1: From the given list of programs (available online), students should
write at-least 3 programs (any) flowchart/algorithm/program in the observation
book (separate notebook)
● Step 2: Verifying the observation book by the instructor and randomly
assigning one questions from the announced list (similar) and two surprise
questions for execution. In the case of no observation book or no preparation,
student will not be permitted to enter the lab and will be marked absent with 0
marks out of 15 for that lab.
● Step 3: Checking the output and awarding marks out of 5 for each.
● Step 4: Uploading the source code and snap shot of the results with the file
name <reg. no.>-1/2/3.c and <reg. no.>-1/2/3.png. (Eg. 20CS01-1.c,
20CS01-2.c, and so on.)
Course Instructors Head of the Department
S1: Aishwary
S2: Y. V. Srinivas
S3: Vidya Maygeri
S4: Girish
Page 7 of 7
S5: Marwa
S6: Rakshitha Kotian
Page 8 of 7