We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
SET A
VELAMMAL INSTITUTE OF TECHNOLOGY
DEPT OF COMPUTER SCIENCE AND ENGINEERING INTERNAL ASSESSMENT- IA 4 ANSWER KEY 2023 - 2024 EVEN SEMESTER
Subject Name: PROGRAMMING IN C Sub code: CS3251
COMPUTER SCIENCE AND I/II Branch: Year/Sem: ENGINEERING Common to: CSE & IT Date: 29/05/2024 Total 60 Duration: 1 Hour 45 Minutes Marks:
PART - A (6×2=12 Marks)
1. What is Structure? Explain with syntax. (2 Marks) CO4 Structure in C is a composite data type that groups variables under a single name. It's defined using struct keyword with member variables of different types. 2. Difference between malloc() and calloc(). (2 Marks) CO4 malloc() allocates uninitialized memory, while calloc() allocates and initializes memory to zero. malloc() is used when initial values are not critical, calloc() for ensuring zero-initialized memory. 3. Write the syntax for pointers to structure. (2 Marks) CO4 struct structure_name { // Members data_type member1; data_type member2; // ... }; struct structure_name *ptr_to_struct; 4. Compare and contrast a structure with an array. (2 Marks) CO4 Structure groups different types of variables under one name, accessed using dot (.) operator. Array stores elements of the same type in contiguous memory, accessed using index notation ([]). 5. Why files are needed? (2 Marks) CO5 Files provide persistent storage for data beyond program execution. They enable data sharing between programs, efficient data processing, and serve as backups to prevent data loss. 6. What do argv and argc indicate in command-line arguments? (2 Marks) CO5 argc is an integer indicating the number of arguments passed to a program, including the program name. argv is an array of strings containing the actual arguments passed to the program from the command line. PART-B (3×16=48 Marks) 7 i)Explain need for nested structure with example Program a. .
i) Explanation: 4 marks (8)
CO Example Program: 4 marks (Understand 4 )
ii) Can a linked list grow dynamically? justify your answer
with example program CO ii) ) Explanation: 4 marks (8) (Create) 4 Example Program: 4 marks
(OR) i. With suitable diagram, explain the concept of single linked list b. ii. Difference between structure and union
i.Explanation with Diagram: 8 marks Apply
(8) ii. Explanation: 4 marks CO 4 Clear distinction and example: 4 marks (Understand (8) ) What is a structure? Create a structure with data members of various types and 8 declare two structure variables. Write a program to read data into these and print the a. . same. Justify the need for structured data type.
Program structure and functionality: 8 marks (16 CO
Create Justification of structured data type: 8 marks ) 4 (OR) Write a C program using structure to prepare the Employee pay roll of a company the b. number of records is created based on the user input Structure Definition: 2 marks User Input and Array Declaration: 2 marks Input loop functionality: 4 marks (16 CO Create Calculation of gross salary: 4 marks ) 4 Display Payroll Information: 2 marks Justification of Structured Data Type: 2 marks 9 Explain in details various operations that can be done on file giving suitable examples a. . Comprehensive explanation of file operations: 12 marks (16 Apply CO Suitable examples demonstrating operations: 4 ) 5 marks (OR) Explain in detail random access in files along with the b. functions used for the same in C.Give suitable examples. Detailed explanation of random access concepts and (16 Apply CO functions: 12 marks ) 5 Clear examples demonstrating random access operations: 4 marks