0% found this document useful (0 votes)
14 views4 pages

Programming Basics: Code Types & Operators

The document provides an overview of programming concepts, including source code, object code, and executable code, highlighting their differences. It also explains various operators such as arithmetic, increment/decrement, relational, logical, bitwise, assignment, conditional, and special operators with examples. This serves as a simplified guide for understanding basic programming syntax and operations.

Uploaded by

Gamer Arjun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Programming Basics: Code Types & Operators

The document provides an overview of programming concepts, including source code, object code, and executable code, highlighting their differences. It also explains various operators such as arithmetic, increment/decrement, relational, logical, bitwise, assignment, conditional, and special operators with examples. This serves as a simplified guide for understanding basic programming syntax and operations.

Uploaded by

Gamer Arjun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

**Programming Notes – Clean & Simplified (English Version)**

--------------------------------------------

### 1. Source Code


Source code is human■readable code written by a programmer using a high■level language such as
C, C++, or Python.
It may include comments for better understanding.
Computers cannot understand source code directly.

**Example:**
```
#include
int main() {
printf("Hello World");
return 0;
}
```

--------------------------------------------

### 2. Object Code


Object code is machine■understandable binary code created after compilation.
It is not human readable.

Examples: `.o`, `.obj`, `.exe` (intermediate output before linking).

--------------------------------------------

### 3. Executable Code


Executable code is the final machine code that the CPU can directly run.
It is produced after linking object code with required libraries.

Example: `[Link]`

--------------------------------------------

### 4. Difference – Object Code vs Executable Code


- Object code = intermediate machine code (after compilation)
- Executable code = final machine code (after linking)
- Executable code is directly runnable; object code is not.

--------------------------------------------
### 5. Arithmetic Operators
Let A = 20, B = 10

+ : A + B = 30
- : A - B = 10
* : A * B = 200
/:A/B=2
%:A%B=0

--------------------------------------------

### 6. Increment / Decrement Operators


Let A = 20

A++ → 20 (then A becomes 21)


++A → 21 immediately

**Example:**
```
int x = 5;
printf("%d", x++); // prints 5
printf("%d", ++x); // prints 7
```

--------------------------------------------

### 7. Relational Operators


Let A = 10, B = 20

A < B → true
A > B → false
A <= B → true
A >= B → false
A == B → false
A != B → true

--------------------------------------------

### 8. Logical Operators

&& → Logical AND


|| → Logical OR
! → Logical NOT
**Example:**
```
(4 != 5 && 4 < 5) // true
(4 == 5 || 4 < 5) // true
!(4 < 5) // false
```

--------------------------------------------

### 9. Bitwise Operators


& → AND
| → OR
^ → XOR
~ → One’s complement
<< → Left shift
>> → Right shift

**Example (A = 60, B = 13)**


A & B = 12
A | B = 61
A ^ B = 49
~A = 195
A << 2 = 240
A >> 2 = 15

--------------------------------------------

### 10. Assignment Operators

= Assign
+= Add then assign
-= Subtract then assign
*= Multiply then assign
/= Divide then assign
%= Modulus then assign
<<= Left shift and assign
>>= Right shift and assign
&= Bitwise AND assign
|= Bitwise OR assign
^= Bitwise XOR assign

--------------------------------------------

### 11. Conditional (Ternary) Operator

**Format:**
condition ? value_if_true : value_if_false;

**Example:**
```
(age >= 21) ? printf("Eligible") : printf("Not Eligible");
```

--------------------------------------------

### 12. Special Operators

sizeof() → returns size of a variable


& → address of variable
* → pointer dereference

**Example:**
```
int a = 10;
printf("%lu", sizeof(a)); // 4 bytes
printf("%p", &a;); // address
```

--------------------------------------------

You might also like