ST.
JOSEPH’S COLLEGE OF ENGINEERING AND TECHNOLOGY
A.S Nagar, Elupatti – Thanjavur.
(Approved by AICTE- New Delhi, Affiliated to Anna University, Chennai.)
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
CS3353 – C Programming and Data Structures
UNIT TEST-II, SEP – 2024
Course Code-Name
ANSWER KEY
Answer All Questions
Part - A (5*2=10 Marks)
1. What is a Structure?
ANS: A structure is something of many parts that is put together. A structure can be a
skyscraper, an outhouse, your body, or a sentence. Structure is from the Latin word
structure which means "a fitting together, building." Although it's certainly used to
describe buildings, it can do more than that.
2. What is Union?
ANS: Union an act or instance of uniting or joining two or more things into one.
especially : the formation of a single political unit from two or more separate and
individual units. : something that is made one : something formed by a combining or
coalition of its members: as.
3. Write the syntax for creating an union.
ANS: Syntax of Union in CHere is a basic syntax to declare a union: union Data { int
i; float f; char str[20]; }; In this union named Data, an integer, a float, and a character
array share the same memory space. At any given time, only one of them can hold a
value.
4. What are the uses of pointers?
ANS: Uses of pointers:
To pass arguments by reference.
For accessing array elements.
To return multiple values.
Dynamic memory allocation.
To implement data structures.
5. List some of C File handling Operation?
ANS:
File handling is a crucial aspect of any programming language, and C is no exception.
It refers to the process by which data is stored and retrieved from files using a
program. In C, all the data in a program can be stored into a file, and later retrieved or
extracted from the file for use in another program.
Part - B (2*13= 26 Marks)
6. a i) Explain the Preprocessor directives with its types and examples.
ANS: Definition – 3 Marks
Syntax - 3 Marks
Example – 7 Marks
b) Write a C Program to calculate the student’s average marks.
ANS: Definition – 3 Marks
Syntax – 3 Marks
Examples – 7 Marks
7. a) What is a function? Explain with neat program.
ANS: Definition of File - 3 Marks,
Types of Binary File – 6 Marks
Syntax & Example – 4 Marks,
b) Write short notes on Union with example program.
ANS: Syntax – 6 Marks
Examples – 7 Marks
Part - C (1*14= 14 Marks)
8. a) Explain Call by value and call by reference with example program.
ANS: Definition of File Handling - 3 Marks,
Syntax – 4 Marks
Examples – 7 Marks
b) Write short notes on Array. How to write Data into text file and read data
from the file?
ANS : Definition of Array – 3 Marks
Syntax - 4 Marks,
Examples – 7 Marks
Course Instructor HoD