0% found this document useful (0 votes)
15 views5 pages

C Language Theory Exam Updated

Uploaded by

mrhit7
Copyright
© © All Rights Reserved
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
0% found this document useful (0 votes)
15 views5 pages

C Language Theory Exam Updated

Uploaded by

mrhit7
Copyright
© © All Rights Reserved
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/ 5

C Language Theory Exam Preparation Guide

Focus: Topics up to Arrays and Pointers


Book Reference: ANSI C

1. Introduction to C Language
Definition: C is a middle-level programming language developed by Dennis Ritchie at Bell
Labs in the 1970s. It combines the features of both high-level and low-level languages.

Key Points:

- Structured programming language.


- Supports modular programming.
- Efficient and fast execution.
- Portable and widely used.

True/False:

1. C was developed by James Gosling. (False)


2. C is a case-sensitive language. (True)

Question-Answers:

Q1: Who developed the C language?


A: Dennis Ritchie.
Q2: Why is C called a middle-level language?
A: Because it combines the features of both high-level and low-level languages.

3-5 Marks Questions:

Q1: Explain the features of the C programming language.


Q2: Write a short note on the history of C.

2. Data Types and Variables


Definition: Data types define the type of data a variable can store, such as integers,
characters, or floating-point numbers.

Key Points:

- Basic types: int, float, char, double.


- Derived types: Array, Pointer, Structure.
- Modifiers: signed, unsigned, long, short.

True/False:
1. "char" is used to store integer values. (False)
2. "float" is used to store decimal numbers. (True)

Question-Answers:

Q1: What are the basic data types in C?


A: int, float, char, double.
Q2: What is the size of an integer data type?
A: Typically 4 bytes, but it may vary by system.

3-5 Marks Questions:

Q1: What is the difference between signed and unsigned data types?
Q2: Describe the different data types available in C with examples.

3. Operators and Expressions


Definition: Operators are symbols that perform operations on variables and values.

Key Points:

- Arithmetic Operators: +, -, *, /, %.
- Relational Operators: >, <, ==, !=.
- Logical Operators: &&, ||, !

True/False:

1. "=" is used for comparison. (False)


2. "&&" is a logical AND operator. (True)

Question-Answers:

Q1: What is the difference between "=" and "==".


A: "=" is an assignment operator, while "==" is a comparison operator.
Q2: Write an example of a ternary operator.
A: result = (a > b) ? a : b;

3-5 Marks Questions:

Q1: Explain the different types of operators in C.


Q2: What are logical operators? Provide examples.

4. Control Statements
Definition: Control statements determine the flow of program execution based on
conditions or loops.

Key Points:
- Conditional: if, if-else, switch.
- Loops: for, while, do-while.
- Jump: break, continue, goto.

True/False:

1. The "for" loop is an entry-controlled loop. (True)


2. "goto" is used to exit a loop. (False)

Question-Answers:

Q1: What is the difference between "while" and "do-while" loops?


A: "while" checks the condition before execution, while "do-while" checks after execution.
Q2: Write a program to print numbers from 1 to 10 using a for loop.
A: Refer to example programs.

3-5 Marks Questions:

Q1: Explain the syntax and flow of an if-else statement.


Q2: Differentiate between break and continue statements.

5. Functions
Definition: A function is a self-contained block of code designed to perform a specific task.

Key Points:

- Function Declaration and Definition.


- Call by Value and Call by Reference.
- Recursive Functions.

True/False:

1. Functions must return a value. (False)


2. Recursion is when a function calls itself. (True)

Question-Answers:

Q1: Explain Call by Value.


A: Call by Value passes a copy of the variable to the function.
Q2: Write a factorial program using recursion.
A: Refer to example programs.

3-5 Marks Questions:

Q1: Differentiate between Call by Value and Call by Reference.


Q2: Write the syntax and an example of a recursive function.
6. Arrays and Strings
Definition: An array is a collection of similar data types stored in contiguous memory
locations.

Key Points:

- One-Dimensional Arrays: Used to store a list of elements.


- Two-Dimensional Arrays: Used to represent matrices.
- Strings: Array of characters ending with a null character (`\0`).

True/False:

1. Arrays can store multiple data types. (False)


2. Strings are terminated by a null character. (True)

Question-Answers:

Q1: What is an array?


A: An array is a collection of similar data types stored in contiguous memory locations.
Q2: Write a program to find the largest element in an array.
A: Refer to example programs.

3-5 Marks Questions:

Q1: Explain the difference between One-Dimensional and Two-Dimensional arrays.


Q2: Write a program to concatenate two strings.

7. Pointers
Definition: A pointer is a variable that stores the memory address of another variable.

Key Points:

- Declaration: `int *ptr;`


- Initialization: `ptr = &variable;`
- Pointer Arithmetic: Increment, Decrement.
- Pointers with Arrays and Strings.
- Dynamic Memory Allocation: malloc(), calloc(), realloc(), free().

True/False:

1. A pointer stores the value of a variable. (False)


2. `malloc` is used for dynamic memory allocation. (True)

Question-Answers:

Q1: What is a pointer?


A: A pointer is a variable that stores the memory address of another variable.
Q2: Write a program to swap two numbers using pointers.
A: Refer to example programs.

3-5 Marks Questions:

Q1: Explain the concept of pointer arithmetic with examples.


Q2: Write a program to dynamically allocate memory for an integer array.

You might also like