Pic QB (Solved and Readable)
Pic QB (Solved and Readable)
Q2 Constant vs Variable
If (condition1) {
If (condition2) {
} else {
} else {
5. A) What is an Algorithm?
} else if (condition2) {
} else if (condition3) {
} else {
```
Arithmetic Operators:
| `+` | Addition | `a + b` |
| `-` | Subtraction | `a – b` |
| `*` | Multiplication | `a * b` |
| `/` | Division | `a / b` |
Logical Operators:
Input Functions:
Output Functions:
1. Must start with a letter or underscore (_) – Cannot start with a digit.
5. Must be declared before use – Example: int num; before using num.
Name: Start/End
Name: Input/Output
Name: Process
Name: Decision
Name: Flowline
Algorithm:
Flowchart:
Example:
```c
Int age;
Example:
```c
```
Explanation:
- The switch statement is used when multiple conditions depend on the value
of a single variable.
Syntax:
```c
Switch (expression) {
Case value1:
Break;
Case value2:
Break;
Default:
```
Example:
```c
Int choice;
Scanf(“%d”, &choice);
Switch (choice) {
Case 1:
Break;
Case 2:
Break;
Case 3:
Break;
Default:
Printf(“Invalid selection.\n”);
}
16 List of Format Specifiers and Their Uses
%d or %i – Integer (decimal)
%f – Float
%lf – Double
%c – Character
%s – String
%x – Hexadecimal (lowercase)
%X – Hexadecimal (uppercase)
%o – Octal
%u – Unsigned integer
%p – Pointer address
17. Program
#include <stdio.h>
Int main() {
Char operator;
Case ‘+’:
Break;
Case ‘-‘:
Break;
Case ‘*’:
Break;
Case ‘/’:
If (num2 != 0) {
} else {
Break;
Default:
Break;
}
Return 0;