C_Programming_Notes_Answers_Expanded
C_Programming_Notes_Answers_Expanded
----------------------------------------
#include <stdio.h>
int main() {
scanf("%d", &n);
scanf("%d", &a[i]);
scanf("%d", &key);
if(a[i] == key) {
return 0;
return 0;
------------------------------------------------------
#include <stdio.h>
int main() {
int marks[30], i, sum = 0;
float average;
scanf("%d", &marks[i]);
sum += marks[i];
return 0;
------------------------------------------------------
------------------------------------------
-------------------------------------------
PART - A
-----------
- The 'continue' statement skips the current iteration of the loop and moves to the next iteration.
- A global variable is declared outside all functions and is accessible by any function in the
program.
3) Define paradigm:
- The conditional operator in C is a ternary operator `?:` used to replace simple if-else statements.
- Memory in C includes Stack (for static memory), Heap (for dynamic memory using malloc), Code
- 'switch' is used when we have multiple constant values to compare with a single variable.
- 'nested if' can handle ranges and complex expressions that 'switch' cannot.
6) Features of arrays:
- Arrays are collections of elements of the same type stored in contiguous memory.
- They allow random access using index, efficient iteration, and easy traversal.
7) Two-dimensional array:
Access: arr[1][2] represents the element in the 2nd row, 3rd column.
- A function declaration tells the compiler about a function's name, return type, and parameters.
9) Operation of pointers:
- Declaring a pointer: int *ptr;
- Pointers can be used in arrays, functions (call by reference), and dynamic memory allocation
(malloc, free).