0% found this document useful (0 votes)
19 views2 pages

C Programming 16 Marks Answers

The document provides an overview of key concepts in C programming, including operators, arrays, structures, unions, pointers, abstract data types, stacks, sorting algorithms, and file handling. It also covers specific techniques such as infix to postfix conversion, collision resolution methods in hash tables, and tree traversals. Each section includes definitions, examples, and relevant operations to aid understanding for 3rd Semester ECE students.

Uploaded by

tinuja0319
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)
19 views2 pages

C Programming 16 Marks Answers

The document provides an overview of key concepts in C programming, including operators, arrays, structures, unions, pointers, abstract data types, stacks, sorting algorithms, and file handling. It also covers specific techniques such as infix to postfix conversion, collision resolution methods in hash tables, and tree traversals. Each section includes definitions, examples, and relevant operations to aid understanding for 3rd Semester ECE students.

Uploaded by

tinuja0319
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/ 2

C PROGRAMMING – 16 MARKS ANSWERS

------------------------------------
1. OPERATORS IN C
Operators are symbols used to perform operations on variables.
Types: Arithmetic, Relational, Logical, Assignment, Increment/Decrement, Bitwise, Conditional,
Special.

------------------------------------
2. SINGLE AND MULTI-DIMENSIONAL ARRAYS
Single dimensional: int a[5] = {1,2,3,4,5};
Multi-dimensional: int b[2][3] = {{1,2,3},{4,5,6}};
Used for storing multiple data items of same type.

------------------------------------
3. STRUCTURE AND UNION
Structure groups different data types.
Union shares the same memory for all members.

Structure Example:
struct student { int id; char name[20]; float marks; };

Union Example:
union data { int i; float f; char ch; };

------------------------------------
4. SWAPPING TWO NUMBERS
Using temp variable or without temp using arithmetic operators.

------------------------------------
5. POINTERS AND ARRAYS
Pointer can access array elements using *(p+i).
Example: int *p; p=a; printf("%d", *(p+i));

------------------------------------
6. ABSTRACT DATA TYPE (ADT)
Definition: A type defined by its behavior, not implementation.
Examples: Stack, Queue, List.
Advantages: Abstraction, Reusability, Encapsulation, Maintainability.

------------------------------------
7. STACK
Linear data structure following LIFO.
Operations: push(), pop(), peek(), isEmpty().
Used for expression evaluation and recursion.

------------------------------------
8. INFIX TO POSTFIX CONVERSION
Example: A + B / C + D * (E - F) ^ G / H
Postfix: A B C / + D E F - G ^ * H / +

------------------------------------
9. LINEAR vs QUADRATIC PROBING
Both are collision resolution techniques in hash tables.

| Feature | Linear | Quadratic |


|----------|---------|------------|
| Formula | (h + i) % n | (h + i^2) % n |
| Clustering | High | Low |
| Simplicity | Easy | Complex |

------------------------------------
10. TREE TRAVERSALS
Preorder: Root -> Left -> Right
Postorder: Left -> Right -> Root
Example Tree:
A
/BC
/DE
Preorder: A B D E C
Postorder: D E B C A

------------------------------------
11. INSERTION SORT
Builds sorted array one item at a time.
Algorithm compares each element and places it in correct position.

------------------------------------
12. BINARY SEARCH (Key = 18)
Works only on sorted arrays.
Steps: Compare mid → search left/right.
Efficient O(log n) search algorithm.

------------------------------------
13. FILE HANDLING (Store & Display Student Data)
Uses FILE pointer, fopen(), fprintf(), fscanf(), fclose().
Writes and reads name and marks from “student.txt”.

------------------------------------
14. STRING REVERSAL USING STACK
Push all characters of string → Pop to reverse order.
Example: CAT → TAC
Follows LIFO principle.

------------------------------------
Prepared for: 3rd Semester ECE - C Programming (16 Marks)

You might also like