0% found this document useful (0 votes)
4 views3 pages

Java Programming Notes

The document covers fundamental concepts in C programming, including constants, variables, data types, and operators. It explains the declaration and initialization of variables, types of operators, and control structures such as decision-making and looping statements. Additionally, it discusses operator precedence and type conversion in expressions.

Uploaded by

mp1121451
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)
4 views3 pages

Java Programming Notes

The document covers fundamental concepts in C programming, including constants, variables, data types, and operators. It explains the declaration and initialization of variables, types of operators, and control structures such as decision-making and looping statements. Additionally, it discusses operator precedence and type conversion in expressions.

Uploaded by

mp1121451
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
You are on page 1/ 3

C Programming - Constants, Variables, Data Types, Operators, Control Structures

Constants, Variables and Data Types

Constants:

- Fixed values that do not change during execution.

- Declared using `final` keyword.

Example: final int MAX = 100;

Variables:

- Used to store data values.

- Types: int, float, double, char, boolean, String, etc.

Declaration of Variables:

int age;

float salary;

char grade;

Giving Values to Variables:

age = 25;

salary = 50000.50f;

grade = 'A';

Symbolic Constants:

final double PI = 3.14;

Typecasting:

float x = (float) 10 / 3; // Result is 3.333...

Operators & Expressions

Types of Operators:
C Programming - Constants, Variables, Data Types, Operators, Control Structures

- Arithmetic: +, -, *, /, %

- Relational: ==, !=, <, >, <=, >=

- Logical: &&, ||, !

- Assignment: =, +=, -=, etc.

- Increment/Decrement: ++, --

- Conditional (Ternary): (condition) ? true : false

- Bitwise: &, |, ^, ~, <<, >>

Arithmetic Expressions:

int result = (a + b) * c;

Evaluation of Expressions:

- Follows operator precedence and associativity rules.

Type Conversion in Expressions:

- Implicit: Widening (int to float)

- Explicit: Narrowing (float to int) using casting

Operator Precedence (High -> Low):

1. ()

2. ++, --, !

3. *, /, %

4. +, -

5. <, >, <=, >=

6. ==, !=

7. &&

8. ||

9. =, +=, -=, etc.

Decision Making, Branching & Looping


C Programming - Constants, Variables, Data Types, Operators, Control Structures

Control Statements:

- if, if-else, nested if, else-if ladder, switch-case

Example:

if (age > 18) { ... }

switch (choice) { case 1 -> ...; }

Looping Statements:

- for, while, do-while

Examples:

for (int i = 0; i < 10; i++) { ... }

while (i < 10) { ... }

do { ... } while (i < 10);

Jump in Loops:

- break: exits loop

- continue: skips current iteration

- return: exits method

Labelled Loops:

outer: for (...) {

for (...) {

if (condition) break outer;

You might also like