Sie sind auf Seite 1von 3

Practice Exercises

Subject: Programming in C

Semester: I
Batch: 2013-15

Q 1) Get a date from user (in the form dd/mm/yyyy) and check whether the date is valid or not. Generate
the next date if the entered date is valid.
Q 2) Generate the following patters using iterative constructs (remember to provide flexibility in terms of
number of rows generated)

1)

A
ABA
ABCBA
ABCDCBA

2)

1
1
1
1
1

1
2

3
4

1
3

1
4

Q 3) Convert a number to a word statement e.g. 1245 should get converted to One thousand two

hundred and forty five.


Q 4) Convert the base of a number: Base X to Base Y; base ranging from 2 to 36
Q 5) The question for 2D array :
Create 2D containing marks of 60 students in 5 subjects. Use this data to generate the
following information:
i) Overall grade (A, B, C, D, E...) of each student.
ii) Marks of topper of each subject
iii) Roll nos. of toppers of each subject
iv) Overall max score
v) Roll nos. & codes of subject having overall max. score
Q 6) 3D Array
Extend the previous mark list to a 3D array, the third dimension represents marks in 3
internal exams. Calculate:
i) Total marks of all students in each subject considering best two of three internals
ii) Total marks of a particular student in each subject considering best two of three internals
iii) Overall Topper(s) of Internal I
iv) Overall Topper(s) (considering all Internals)
Q 7) Structures
i) Define a structure Student {Roll, Name, DateOfBirth}. Write functions accept, display,
to accept and display variables of type Student respectively.
ii) Also write functions acceptAll, displayAll to perform the same action on an array of type
struct Student
Page 1 of 3

Practice Exercises
Subject: Programming in C

Semester: I
Batch: 2013-15

iii) Define a structure Result {Roll, Semester, Marks[5]}.


iv) Write function to generate result of a student (given her name) in a particular semester.
v) Use these structures and functions simulate a simple Examination System capable of accepting
student and exam data and generating a students result.

Q 8)

Write a menu driven program to perform Create Read Update Delete (CRUD) operations on an
array of structures.

Q 9) Modify the application created in the previous question, so that the data can be saved on
and retrieved from persistent storage.
Q 10)
i)
ii)
iii)
iv)
v)
vi)

String operations (define functions):


Case conversion
Concatenation
Check for palindrome
Find a string in another
Replace a part of string with another
Sort an array of strings

Q 11) Write RECURSIVE functions to


i) Factorial N
ii) Sum of first N natural numbers
iii) X raised to power Y

iv) Perform Binary search


v) Perform String Reversal
vi) Checking if a string is a palindrome
Q 12) Use block-I/O to maintain records of students in a binary file. The program should provide for
following operations:
i) Insert a record on basis of roll number.
ii) Insert a record on basis of position.
iii) Search for a record.
iv) Modify a record.
v) Remove a record.
vi) Display all records.

Q 13) Write a program to search for a word in a file and replace it with another.
Q 14)
Use formatted I/O to maintain records of students in a text file. The program should provide for
following operations:
i) Insert a record on basis of roll number.
ii) Insert a record on basis of position.
iii) Search for a record.
iv) Modify a record.
v) Remove a record.
vi) Display all records.
vii) Use tab as field separator and new-line as record separator.

Q 15)
i)
ii)
iii)

Write functions to create two dimensional arrays dynamically using:


Pointer to an array
Array of pointers
Pointer to a pointer
Page 2 of 3

Practice Exercises
Subject: Programming in C
Q 16)
i)
ii)
iii)

Semester: I
Batch: 2013-15

Write functions to perform following operations on a Linked List:


Add a node at any position
Search for some data value
Delete a node from any position

Q 17) Unions
Define two structures Rectangle and Oval. Use these to define a Union Shape. Write a
function CalculateArea that takes a parameter of type Shape and returns area of appropriate
Shape.
Q 18) Demonstrate the use of callback functions through library function qsort and bsearch to
search for a structure in an array of structures on basis of rollno.
Q 19) Use an integer variable to store the color values RGB (8-bits each) using bit operations.
Write functions to get / set the desired color value.
Q 20) Write a program that uses system calls to read an inode of a file whose name is passed as
command line parameter. The program should display the rights the owner, group members
and others have on the file.
Q 21) Write a program that provides menu options to change the ownership, group ownership
and permissions on the file. The required data can be accepted interactively from the user.
Q 22) Write a program that creates a child process and displays the process id and parent
process ids of both the parent and the child process. The parent process should display its
data after only the child process has terminated.
Q 23) Write a program that displays the contents of the directory (using system) that is passed
as command line parameter. The program should then display a menu providing options to
copy, move or delete the file. The desired operation should be carried through a child
process whose memory area is overlaid with the required shell command.
Q 24) Write a program to demonstrate thread creation. The thread created should simply print a
fixed message as many times as required by the main program (pass data to the thread).
********

Page 3 of 3

Das könnte Ihnen auch gefallen