What is a variable?
A named memory location that stores data which can change during execution.
age = 25
Variable vs constant?
Variable: value changes (int age)
Constant: value fixed (final double PI)
Local vs global variable?
Local: inside function, limited scope.
Global: outside all, accessible everywhere.
Variable naming rules?
Start with letter/underscore, no spaces, case‑sensitive, not keywords.
✔ totalScore ✘ 2score
Common data types?
Integer, Float, String, Boolean.
int a=5; float b=3.14; String s="Hi"; bool flag=true;
Integer vs Float?
Integer – whole numbers (5). Float – decimal (5.7).
Type conversion examples?
Implicit: double x = 5;
Explicit: int y = (int)5.7;
What is an array?
Collection of same‑type elements stored contiguously, accessed by index.
int numbers[5] = {1,2,3,4,5};
Array types?
1D, 2D, multi‑dimensional.
int matrix[3][3];
Logical operators?
AND (&&), OR (||), NOT (!), XOR.
Boolean operators?
Operate on true/false – same as logical operators.
How loops work?
Repeat code until condition false.
while(i<5){ i++; }
Loop types?
for, while, do‑while, foreach.
Sum first 10 natural numbers?
sum = 0
for i in range(1,11): sum+=i
print(sum)
Multiplication table?
n = int(input())
for i in range(1,13):
print(n,'x',i,'=',n*i)
Reverse digits?
n = input()[::-1]
print(n)
Prime number check?
prime = True
for i in range(2,n):
if n%i==0: prime=False
What is a flowchart?
Graphical representation of an algorithm using standard symbols.
Flowchart symbols?
Oval (start/stop), rectangle (process), parallelogram (I/O), diamond (decision).
Algorithm definition?
Step‑by‑step procedure to solve a problem.
Compiler vs interpreter?
Compiler: whole program at once (C++).
Interpreter: line‑by‑line (Python).
Syntax vs logical error?
Syntax: grammar mistake.
Logical: wrong output, runs but incorrect.
What is debugging?
Process of finding and fixing errors in code.
What is a pointer?
Variable that stores memory address of another variable.
int *p = &x;
Python: declare integer?
age = 10 (dynamic typing).
Java int vs Integer?
int: primitive; Integer: wrapper class (object).