Class 10 Computer - Chapter 4 Notes
1. Conditional Control Structure
- Conditional statements control the flow of the program.
- Types:
- if
- if-else
- else-if ladder
- switch-case
- Example:
if (a > b) {
printf("a is greater");
} else {
printf("b is greater");
- switch-case is used for multiple selections:
switch (choice) {
case 1: printf("Option 1"); break;
case 2: printf("Option 2"); break;
default: printf("Invalid");
2. Data and Repetition (Loops and Arrays)
- Arrays:
- Arrays are used to store multiple values of the same type.
- Example:
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[0]); // prints 1
- Loops:
- Used to execute a block repeatedly.
Class 10 Computer - Chapter 4 Notes
- Types:
- for loop:
for (int i = 0; i < 5; i++) {
printf("%d", i);
- while loop
- do-while loop
- Nested Loops:
- A loop inside another loop.
- Example:
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf("* ");
printf("\n");
3. Useful Links for PDFs
- My Skill Star Notes: [Link]
- Freeilm Chapter 4 PDF: [Link]
- Scribd Notes: [Link]