WHAT IS C LANGUAGE?
C LANGUAGE IS A PROGRAMMING LANGUAGE.
IT IS WIDELY USED IN PROGRAMMING SYSTEM ,SOFTWARE DEVELOPMENT.
IT IS CREATED BY RITCHE OR WE CAN SAY DENNIS RITCHIE IN 1972 .
IT IS HIGH LEVEL PROGRAMMING LANGUAGE .
WHAT IS VARIABLE ?
A VARIABLE IS THE NAME OF GIVEN MEMORY LOCATION THAT IS USED TO STORE DATA.
FOR EXAMPLE : INT A;
HERE INT IS NAME OF DATA TYPE AND A IS A VARIABLE
LETS TAKE ONE MORE EXAMPLE
INT AGE;
HERE INT IS DATA TYPE ,MEANS WHICH TYPE OF DATA WE NEED TO STORE AND HERE WE ARE STORING INTEGER TYPE DATA.
AND AGE IS VARIABLE TO STORE AGE , OF INTEGER TYPE .
FOR EXAMPLE ,IN REAL LIFE THERE IS A PEN STAND TO KEEP PENS,AND THERE IS A CUPBOARD TO KEEP CLOTHES.
RULES OF VARIABLE :
1. START WITH A LETTER OR UNDERSCORE .
(CAN NOT START WITH A NUMBER ).
2. CASE SENSITIVE : MYVAR AND myvar ARE CONSIDERED DIFF. .
3. NO SPACE .
( YOU CAN USE UNDERSCORE INSTEAD OF SPACE ).
4. SPECIAL CHARACTER LIKE @ % ! ETC ARE NOT ALLOWED .
FOR EXAMPLE : INSTA ID IT WILL CONTAIN UNDERSCORE NOT SPACE ,OR WE CAN SAY INSTEAD OF SPACE WE CAN USE UNDERSCORE IN INSTA ID AS WELL AS IT CONTAIN CHARACTER LETTER NUMBER BUT NOT SPECIAL CHAR .
DATA TYPE ?
1. Arithmetic Operators
Used for basic mathematical operations:
+: Addition-: Subtraction*: Multiplication/: Division%: Modulus (remainder after division)
2. Relational (Comparison) Operators
Used to compare two values and return a boolean result (1 for true, 0 for false):
==: Equal to!=: Not equal to<: Less than>: Greater than<=: Less than or equal to>=: Greater than or equal to
3. Logical Operators
Used for logical operations, often in conditional statements:
&&: Logical AND||: Logical OR!: Logical NOT
4. Bitwise Operators
Used to perform operations at the bit level:
&: Bitwise AND|: Bitwise OR^: Bitwise XOR~: Bitwise Complement<<: Left shift>>: Right shift
5. Assignment Operators
Used to assign values to variables:
=: Simple assignment+=: Add and assign (a += bis equivalent toa = a + b)-=: Subtract and assign*=: Multiply and assign/=: Divide and assign%=: Modulus and assign
6. Increment and Decrement Operators
Used to increase or decrease a value by 1:
++: Increment (e.g.,i++or++i)--: Decrement (e.g.,i--or--i)
7. Conditional (Ternary) Operator
A shorthand for if-else statements:
? :: Conditional expression (condition ? true_value : false_value)
8. Special Operators
a. Sizeof Operator
Used to determine the size of a data type or variable:
sizeof(data_type)
b. Address-of and Pointer Operators
&: Address-of operator*: Dereference (pointer) operator
c. Comma Operator
,: Allows multiple expressions to be evaluated in a single statement. The last expression’s value is returned.
9. Miscellaneous Operators
.: Member selection for structures->: Member selection through a pointer to a structure(type): Type casting[]: Array subscript(): Function call
1. Parentheses ()
- Highest precedence: Anything inside parentheses is evaluated first.
- Example:
2 + (3 * 4)→2 + 12=14
2. Unary Operators
- Includes:
+,-(unary minus),++(increment),--(decrement),!(logical NOT), and~(bitwise NOT). - Example:
-5 + 3→-5 + 3=-2
3. Multiplicative Operators
- Includes:
*(multiplication),/(division),%(modulus). - Evaluated from left to right.
- Example:
10 / 2 * 5→5 * 5=25
4. Additive Operators
- Includes:
+(addition),-(subtraction). - Example:
10 + 5 - 3→15 - 3=12
5. Relational Operators
- Includes:
<,<=,>,>=(less than, greater than, etc.). - Example:
5 < 10→true
6. Equality Operators
- Includes:
==(equal to),!=(not equal to). - Example:
5 == 5→true
7. Logical AND &&
- Example:
true && false→false
8. Logical OR ||
- Example:
true || false→true
9. Assignment Operators
- Includes:
=,+=,-=,*=,/=,%=(assignment and compound assignment). - Evaluated last.
- Example:
x = 5 + 3→x = 8
Associativity
- When operators have the same precedence, associativity determines the evaluation order:
- Left-to-right associativity: Most operators like
+,-,*,/,%, and relational operators. - Right-to-left associativity: Unary operators (
++,--), assignment operators (=,+=, etc.).
- Left-to-right associativity: Most operators like


No comments:
Post a Comment