Main Programming Language Terms with Diagrams and Examples
1. Variable
A container to store data values.
Think of it like a box where you can put something (a number, a word, etc.).
Example (Python):
age = 25
name = "Alice"
2. Data Types
Specify the kind of data a variable can hold.
Common data types: integer, float, string, boolean.
Example (C++):
int age = 25;
float price = 19.99;
char grade = 'A';
bool isActive = true;
3. Operators
Symbols that perform operations on variables and values.
Types: arithmetic (+, -), relational (>, <), logical (&&, ||).
Example (Java):
int a = 10, b = 5;
int sum = a + b;
boolean result = a > b;
4. Conditionals
Used to make decisions in a program.
Common: if, else if, else.
Example (Python):
if age >= 18:
print("You can vote")
else:
print("You cannot vote")
Page 1
Main Programming Language Terms with Diagrams and Examples
5. Loops
Used to repeat a block of code multiple times.
Common loops: for, while.
Example (C++):
for (int i = 1; i <= 5; i++) {
cout << i << endl;
}
6. Functions (or Methods)
A block of code designed to do a particular task.
Helps in reusing code.
Example (Python):
def greet(name):
print("Hello, " + name)
greet("Alice")
7. Class & Object (OOP Concept)
Class: Blueprint for creating objects.
Object: Instance of a class.
Example (Java):
class Car {
String color = "red";
}
public class Main {
public static void main(String[] args) {
Car myCar = new Car();
[Link]([Link]);
}
}
8. Array
Page 2
Main Programming Language Terms with Diagrams and Examples
A collection of similar data items stored in contiguous memory.
Example (C++):
int numbers[3] = {1, 2, 3};
9. String
A sequence of characters (text data).
Example (Python):
message = "Hello, World!"
print([Link]())
10. Comments
Notes in code that are ignored by the computer, used to explain what the code does.
Example (C++):
// This is a single-line comment
/*
This is
a multi-line
comment
*/
11. Input/Output
Input: Taking data from the user.
Output: Showing data to the user.
Example (Python):
name = input("Enter your name: ")
print("Hello, " + name)
12. Loop Control Statements
break: Exits the loop.
continue: Skips current iteration.
Example (Python):
for i in range(5):
Page 3
Main Programming Language Terms with Diagrams and Examples
if i == 3:
break
print(i)
13. Inheritance (OOP)
A class can use properties and methods of another class.
Example (Python):
class Animal:
def sound(self):
print("Animal sound")
class Dog(Animal):
pass
d = Dog()
[Link]()
14. Exception Handling
Handling errors gracefully so the program doesn't crash.
Example (Python):
try:
num = int(input("Enter a number: "))
print(10 / num)
except ZeroDivisionError:
print("Cannot divide by zero!")
15. Recursion
A function that calls itself.
Example (Python):
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n-1)
Page 4
Main Programming Language Terms with Diagrams and Examples
print(factorial(5)) # Output: 120
Page 5