C PROGRAMMING AND DATA STRUCTURESImportant Questions _________________________________________________________________________
UNIT - IVStructures :
Definition, initializing, assigning values, passing of structures as arguments, Arrays of structures,pointers to structures, self referential structures. Unions, typedef, bit fields, C program examples.
1.What is the main difference between a structure and union in C?2.Write C functions to perform addition and multiplication operations on two complexnumbers use a structure in C to represent a complex number.3.Write a C program to display the contents of a text file.4
Explain with example how a structure can be organized in the ‘C’ language?5. Write a C program to print maximum marks in each subject along with the name of thestudents by using structures. Take 3 subjects and 3 students records.6. Explain the different ways of passing structure as arguments in functions.7. Write a C program to illustrate the method of sending an entire structure as a parameter to a function.8.How to compare structure variables? Give an example.9.Define a structure type struct ABS, that contains name, age, designation, and salary.Using this structure, write a C program to read this information for one person from thekeyboard and print the same on the screen.10.Write a C program to illustrate the use of structure pointer.11.Explain the effects of the following statements:(i). int a, *b = &a; (ii). int p, *p; (iii). char *s; (iv). a = (float*)&X;12.How are structure elements accessed using pointer? Which operator is used? Give anexample.13.Write a program to use structure within union. Display the contents of structure elements.14.Write a C program to copy the contents of a text file to another file. The program shouldtake the file names (source file and destination file names) from the command-line.15.Consider a structure master includes the information like name, code, pay, experience.Write a program to delete and display the information contained in master variables for agive code.16.A
company markets Hardware items. Create a structure “hwItem” that stores the titleof the item, it’s price, an array of three floats so that it can record the sale in rupees of a particular item for the last three months, category of the item and it’s original equipmentmanufacturer. Write a short program that provided facility to read N no. of itemsinformation, append new item, and displays all records.17. Illustrate the declaration of three character pointer variables using typedef and also usinga macro definition18. Create a structure to store the gender of person, marital status (single, married, divorcedor widowed), one of the eight branches and can choose any 15 subjects. Using bitfieldshighlight the C language’s memory optimization.19. Write a programme to read an integer and using shift operator convert the same to binaryformat.20. Give an example for OR, AND and SHIFT operators highlighting their advantage.21. What is a pointer to a function ? Give an example of its usage highlighting its advantage.
Computer Programming and Data structures 3