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

2marks Paper1

The document provides answers to Section A questions related to programming concepts, including identifiers, symbolic constants, type conversion, if..else statements, and more. Each answer includes definitions, examples, and differentiations between related terms. Key topics covered include arrays, recursive functions, structures, unions, pointers, binary files, and macros.

Uploaded by

samxtrx
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 views4 pages

2marks Paper1

The document provides answers to Section A questions related to programming concepts, including identifiers, symbolic constants, type conversion, if..else statements, and more. Each answer includes definitions, examples, and differentiations between related terms. Key topics covered include arrays, recursive functions, structures, unions, pointers, binary files, and macros.

Uploaded by

samxtrx
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/ 4

Here are the answers to Section A questions (each answer has 3 points):

---

Model Question Paper I

1. What is an identifier? Give an example.

An identifier is the name used to identify variables, functions, or arrays in a program.

It must begin with a letter or an underscore.

Example: int number; where number is an identifier.

2. What is a symbolic constant? Give an example.

A symbolic constant is a name that substitutes a constant value in a program.

It is defined using the #define preprocessor directive.

Example: #define PI 3.14

3. What is type conversion? Mention its types.

Type conversion changes the data type of a variable to another type.

Types:

1. Implicit conversion (type promotion).

2. Explicit conversion (type casting).

4. What is an if..else statement? Write the syntax.

if..else is a decision-making statement that executes code based on a condition.

Syntax:

if (condition) {
// Code if true
} else {
// Code if false
}

Example:

if (x > 0) printf("Positive");
else printf("Negative");

5. Differentiate between break and continue.

break: Terminates the loop or switch statement.

continue: Skips the current iteration and proceeds with the next iteration.

Example:

for (int i = 0; i < 5; i++) {


if (i == 2) continue; // Skips 2
printf("%d", i);
}

6. What are recursive functions?

A recursive function calls itself to solve smaller sub-problems.

It must have a base condition to terminate the recursion.

Example:

int factorial(int n) {
if (n == 0) return 1;
return n * factorial(n - 1);
}

7. What is an array? Mention its types.

An array is a collection of elements of the same data type stored in contiguous memory.

Types:

1. One-dimensional array.

2. Two-dimensional array.
3. Multi-dimensional array.

8. What is a nested structure in C?

A nested structure is a structure within another structure.

Used to represent complex data models.

Example:

struct Address {
int houseNo;
char city[20];
};
struct Student {
char name[20];
struct Address addr;
};

9. What is a union? Give an example.

A union is a special data type where all members share the same memory.

Only one member can hold a value at a time.

Example:

union Data {
int i;
float f;
};

10. What is a pointer?

A pointer is a variable that stores the memory address of another variable.

Syntax: int *ptr;

Example:

int x = 10;
int *ptr = &x;
11. What is a binary file?

A binary file contains data in binary format (not readable as text).

Faster to access and efficient for large data storage.

Example: Storing images or executables.

12. Mention the types of macros.

Object-like macros: Replaces a name with a value.

Function-like macros: Replaces a name with an expression.

Example:

#define PI 3.14 // Object-like


#define SQUARE(x) ((x) * (x)) // Function-like

---

Let me know if you'd like answers for Model Question Paper II and III or any specific
question!

You might also like