C Programing Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

1

SEMESTER I/ II
COMPUTER PROGRAMMING LABORATORY

Sub Code: 14CPL 16 / 14CPL26 IA Marks : 25
Hrs/ Week: 03 Exam Hours : 03
Total Hrs.: 42 Exam Marks : 50

PART A : Demonstration of Personal Computer and its Accessories

Demonstration and Explanation on Disassembly and Assembly of a Personal
Computer by the faculty-in-charge. Students have to prepare a write-up on the
same and include it in the Lab record and evaluated.

Laboratory Session-1: Write-up on Functional block diagram of Computer, CPU, Buses,
Mother Board, Chip sets, Operating System & types of OS, Basics of Networking &
Topology and NIC.

Laboratory Session-2: Write-up on RAM, SDRAM, FLASH memory, Hard disks, Optical
media, CD-ROM/R/RW, DVDs, Flash drives, Keyboard, Mouse, Printers and Plotters.

Note: These TWO Laboratory sessions are used to fill the gap between theory classes and
practical sessions.

PART B: Problem Solving in C

Implement the programs with WINDOWS / LINUX platform using appropriate C
compiler.

1. Design and develop a flowchart or an algorithm that takes three coefficients (a, b, and c)
of a Quadratic equation (ax
2
+bx+c=0) as input and compute all possible roots. Implement
a C program for the developed flowchart/algorithm and execute the same to output the
possible roots for a given set of coefficients with appropriate messages.

2. Design and develop an algorithm to find the reverse of an integer number NUM and
check whether it is PALINDROME or NOT. Implement a C program for the developed
algorithm that takes an integer number as input and output the reverse of the same
with suitable messages. Ex: Num: 2014, Reverse: 4102, Not a Palindrome
3.
3a. Design and develop a flowchart to find the square root of a given number N.
Implement a C program for the same and execute for all possible inputs with
appropriate messages. Note: Dont use library function sqrt(n).

3b. Design and develop a C program to read a year as an input and find whether it is leap
year or not. Also consider end of the centuries.

2
4. Design and develop an algorithm for evaluating the polynomial f(x) = a
4
x
4
+ a
3
x
3
+ a
2
x
2

+ a
1
x + a
0,
for a given value of x and its coefficients using Horners method.
Implement a C program for the developed algorithm and execute for different sets of values of
coefficients and x.

5. Write C Program to compute Sin(x) using Taylor series approximation given by
Sin(x) = x - (x
3
/3!) + (x
5
/5!) - (x
7
/7!) + .
Compare the result with the built- in Library function and print both the results.

6. Develop, implement and execute a C program that reads N integer numbers and arrange
them in ascending order using Bubble Sort technique. Extend the program to perform a
search operation on these sorted numbers by accepting a key element from the user
applying Binary Search method. Report the result SUCCESS or FAILURE as the case
may be.

7. Develop, implement and execute a C program that reads two matrices A (m x n )
and B (p x q ) and Compute the product A and B. Read matrix A in row major order
and matrix B in column major order. Print both the input matrices and resultant matrix
with suitable headings and in matrix format. Program must check the compatibility of
orders of the matrices for multiplication. Report appropriate message in case of
incompatibility.

8. Write and execute a C program that
i. Implements string copy operation STRCOPY(str1,str2) that copies a string
str1 to another string str2 without using library function.
ii. Reads a sentence and prints frequency of each of the vowels and total count of
consonants.
9.
a. Design and develop a C function RightShift(x ,n) that takes two integers x and n
as input and returns value of the integer x rotated to the right by n positions. Assume
the int egers are unsigned. Write a C program that invokes this function with different
values for x and n and tabulate the results with suitable headings.

b. Design and develop a C function isprime(num) that accepts an integer argument
and returns 1 if the argument is prime, a 0 otherwise. Write a C program that invokes
this function to generate prime numbers between the given range.

10. Develop a function in C called MatchAny(s1,s2) that takes two string arguments and
does the following task:
i) if s1 is substring of s2, Returns 1 along with the first location in the string s2,
ii) if s1 is equal to s2 , returns 0 and
iii) otherwise, returns -1.
Write a C program that invokes MatchAny(s1,s2) for different input strings and output
both the strings s1 & s2 with the return value in tabular form. Note: Do not use the
standard library functions.

3
11. Draw the flowchart and write a recursive C function to find the factorial of a number,
n!, defined by fact(n)=1, if n=0. Otherwise fact(n)=n*fact(n-1). Using this function,
write a C program to compute the binomial coefficient
n
C
r
. Tabulate the results for
different values of n and r with suitable messages.

12. Given two text documentary files Ramayana.in and Mahabharatha.in. Write a C
program to create a new file Karnataka.in that appends the content of file
Ramayana.in to the file Mahabharatha.in. Display the contents of output file
Karnataka.in on to screen. Also find number of words and newlines in the output file.

13. Write a C program to maintain a record of n student details using an array of structures
with four fields (Roll number, Name, Marks, and Grade). Each field is of an appropriate
data type. Print the marks of the student given student name as input.

14. a. Write a C program using pointers to compute the sum of all elements stored in an array
A[n]. Where n is the number of elements.
b. Write a C program to find sum of n elements entered by the user. Demonstrate the
program using functions malloc() to allocate memory dynamically and free() to
deallocate.
15. a. Write a C program using pointers to find the median of a list of members.
b. Write a C program to find first minimum element and its position in an unsorted array.
Use pointer technology.

Reference Book:
1. Reema Thareja, Computer Fundamentals and Programming in C, Oxford Press, 2012.



Practical Examination Procedure:

1. Part - A experiment is a demo experiment only and shall not be included in
practical exam.

2 . Part B: All experiments are to be included for practical examination.

3. Students are allowed to pick one experiment from the lot.
4. Strictly follow the instructions as printed on the answer script for breakup of marks
5. Change of experiment is allowed only once and 15% Marks should be deducted
from the procedure part.

You might also like