0% found this document useful (0 votes)
5 views6 pages

U23CST21 Programming in C Question Set

The document is a question set for a coaching class on C programming, covering various topics such as the structure of a C program, data types, decision-making statements, arrays, functions, pointers, structures, unions, and file processing. It includes both 16-mark and 2-mark questions with key points and answer keys for each topic. The content is structured into five units, each focusing on different aspects of C programming.

Uploaded by

deepansri1981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

U23CST21 Programming in C Question Set

The document is a question set for a coaching class on C programming, covering various topics such as the structure of a C program, data types, decision-making statements, arrays, functions, pointers, structures, unions, and file processing. It includes both 16-mark and 2-mark questions with key points and answer keys for each topic. The content is structured into five units, each focusing on different aspects of C programming.

Uploaded by

deepansri1981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

U23CST21 - PROGRAMMING IN C

Question Set for Coaching Class

UNIT I – BASICS OF C PROGRAMMING


16-MARK QUESTIONS (Hints only)
1. Explain the structure of a C program with an example. Describe each component in
detail.
Key Points:
• Documentation Section
• Link Section
• Definition Section
• Global Declaration Section
• main() function section
• Subprogram Section (User-defined functions)
2. Discuss various data types in C. How are constants and keywords used in C
programming?
Key Points:
• Basic Data Types (int, char, float, double)
• Derived Data Types (arrays, pointers, structures, unions)
• Constants: #define, const keyword
• Keywords: List of reserved words in C (int, char, if, else, etc.)
3. Explain decision-making statements and looping statements in C with suitable
examples.
Key Points:
• if, if-else, nested if, switch
• for loop, while loop, do-while loop
• Syntax and examples
4. What is the compilation process in C? Explain the role of preprocessor directives.
Key Points:
• Steps: Preprocessing → Compilation → Assembly → Linking → Loading
• Preprocessor Directives: #include, #define, #ifdef

2-MARK QUESTIONS (Answer Key)


1. Define programming paradigms.
o Programming styles like procedural, object-oriented, etc.
2. What are enumeration constants?
o User-defined named integer constants using enum.
3. Name any two input/output statements in C.
o printf(), scanf()
4. Define precedence and associativity.
o Rules that determine the order of evaluation of operators.
5. List any four types of operators in C.
o Arithmetic, Relational, Logical, Assignment.
6. What is the purpose of the switch statement?
o Used for multi-way branching based on a variable’s value.
7. Write the syntax of a while loop.
o while(condition) { statements; }
8. What are keywords? Give two examples.
o Reserved words like int, return.
9. What is the significance of the #define directive?
o To define symbolic constants.
10. What is an assignment statement?
• Assigns value to a variable, e.g., x = 5;

UNIT II – ARRAYS AND STRINGS


16-MARK QUESTIONS
1. Explain the declaration, initialization, and accessing of one-dimensional arrays with an
example.
Key Points:
• Declaration Syntax
• Initialization (static and dynamic)
• Accessing elements (indexing)
• Example program
2. How are two-dimensional arrays stored and accessed in C? Write a program for matrix
addition.
Key Points:
• Declaration and initialization of 2D arrays
• Row-major storage
• Accessing elements
• Program for matrix addition
3. Write and explain a C program to perform selection sort on an array.
Key Points:
• Selection Sort Algorithm
• Finding minimum element
• Swapping elements
• Complete C program
4. Write a C program to perform string operations: length, comparison, and concatenation.
Key Points:
• String handling functions (strlen(), strcmp(), strcat())
• Program demonstrating these operations

2-MARK QUESTIONS (Answer Key)


1. How do you declare a one-dimensional array?
o int arr[10];
2. Write the syntax for initializing a 2D array.
o int matrix[2][3] = {{1,2,3},{4,5,6}};
3. What is the default initial value of an array element?
o Garbage value unless initialized.
4. Define string in C.
o Array of characters ending with null character '\0'.
5. Name any two string functions in C.
o strlen(), strcpy()
6. What does strcmp() function do?
o Compares two strings.
7. Mention the difference between strlen() and strcpy().
o strlen() gives length; strcpy() copies a string.
8. What is linear search?
o Search each element sequentially.
9. Define binary search.
o Search by repeatedly dividing the array into halves.
10. Write the syntax for accessing a character in a string.
o str[index];

UNIT III – FUNCTIONS AND POINTERS


16-MARK QUESTIONS
1. What is modular programming? How is it achieved in C using functions?
Key Points:
• Concept of Modular Programming
• Advantages
• Role of Functions
• User-defined and built-in functions
2. Explain recursion with an example. Write a recursive program for binary search.
Key Points:
• Definition of Recursion
• Base Case and Recursive Case
• Example program for binary search
3. Describe pointers and pointer arithmetic with examples.
Key Points:
• Pointer basics
• Pointer operations (+, -, ++, --)
• Examples demonstrating pointer arithmetic
4. Discuss array of pointers. Differentiate pass by value and pass by reference using
suitable examples.
Key Points:
• Array of Pointers concept
• Pass by value: copy passed
• Pass by reference: address passed

2-MARK QUESTIONS (Answer Key)


1. What is a function prototype?
o Declaration of function before main.
2. Define recursion.
o A function calling itself.
3. List two built-in string functions.
o strlen(), strcpy()
4. What is the use of the math.h library?
o Provides mathematical functions like sqrt(), pow().
5. Write the syntax to declare a pointer.
o int *p;
6. What is pointer arithmetic?
o Performing operations like increment or decrement on pointers.
7. What is an array of pointers?
o Array storing addresses.
8. Differentiate pass by value and pass by reference.
o Value: copy; Reference: address.
9. How do you call a function in C?
o functionName(arguments);
10. Write an example to declare a function that returns an integer.
o int sum(int a, int b);

UNIT IV – STRUCTURES AND UNION


16-MARK QUESTIONS
1. Define structures. How do you declare, initialize, and access structure members? Give
examples.
Key Points:
• Structure definition
• Declaration and Initialization
• Access using dot operator
• Example
2. Explain nested structures and array of structures with suitable examples.
Key Points:
• Structure inside another structure
• Array of structures
• Example programs
3. What is dynamic memory allocation? Explain how it is used in singly linked lists.
Key Points:
• malloc(), calloc()
• Linked list node creation
• Insertion, Traversal operations
4. Differentiate between structures and unions with examples. Explain the use of typedef.
Key Points:
• Structure: separate memory
• Union: shared memory
• typedef usage

2-MARK QUESTIONS (Answer Key)


1. What is a structure?
o User-defined data type to group variables.
2. How do you access structure members?
o Using dot operator (.).
3. Define nested structure.
o Structure inside another structure.
4. What is a pointer to a structure?
o Pointer that points to a structure variable.
5. Write the syntax for array of structures.
o struct student s[10];
6. Define self-referential structure.
o Structure containing pointer to same structure type.
7. What is dynamic memory allocation?
o Allocating memory during runtime.
8. What is typedef in C?
o Alias for data types.
9. Write a simple syntax to define a union.
o union item { int x; float y; };
10. List any two storage classes in C.
o auto, static.

UNIT V – FILE PROCESSING


16-MARK QUESTIONS
1. What are files in C? Explain file handling functions with examples.
Key Points:
• File definition
• File handling functions: fopen(), fclose(), fscanf(), fprintf()
2. Write a C program to create, write, and read from a sequential access file.
Key Points:
• fopen() with "w" and "r"
• fprintf() for writing
• fscanf() for reading
• Example program
3. Explain random access file operations with examples. How is it different from
sequential access?
Key Points:
• fseek(), ftell(), rewind()
• Random vs Sequential Access
• Example program
4. How are command line arguments used in C? Write a program to demonstrate it.
Key Points:
• argc and argv[]
• Passing arguments from terminal
• Example program

2-MARK QUESTIONS (Answer Key)


1. What is a file in C?
o Storage unit for storing data permanently.
2. Name any two file operations.
o Reading, Writing.
3. Differentiate between sequential and random file access.
o Sequential: Ordered; Random: Direct access.
4. What function is used to open a file?
o fopen()
5. What function is used to read from a file?
o fscanf() or fread()
6. Write the syntax for closing a file.
o fclose(file_pointer);
7. What is a command line argument?
o Arguments passed to main during program execution.
8. Mention any two advantages of using files.
o Permanent storage, easy data sharing.
9. What does fseek() function do?
o Moves file pointer to a specified location.
10. Write the syntax for writing to a file using fprintf().
o fprintf(file_pointer, "format", values);

You might also like