2marks Paper1
2marks Paper1
---
Types:
Syntax:
if (condition) {
// Code if true
} else {
// Code if false
}
Example:
if (x > 0) printf("Positive");
else printf("Negative");
continue: Skips the current iteration and proceeds with the next iteration.
Example:
Example:
int factorial(int n) {
if (n == 0) return 1;
return n * factorial(n - 1);
}
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.
Example:
struct Address {
int houseNo;
char city[20];
};
struct Student {
char name[20];
struct Address addr;
};
A union is a special data type where all members share the same memory.
Example:
union Data {
int i;
float f;
};
Example:
int x = 10;
int *ptr = &x;
11. What is a binary file?
Example:
---
Let me know if you'd like answers for Model Question Paper II and III or any specific
question!