Punjab Tianjin University of Technology: Bs Software Engineering Technology
Punjab Tianjin University of Technology: Bs Software Engineering Technology
COMPUTER PROGRAMMING
ROLL # 02
DATA TYPE
Data types are a fundamental concept that defines the type of data
that a particular variable can hold or represent.
Integer (int): Used for whole numbers. It can be either signed (positive
and negative values) or unsigned (only positive values). Examples
include 1, -5, and 100.
Data Type: Variables have a specific data type that determines what
kind of data they can store. Common data types include integers,
floating-point numbers, characters, strings, Boolean values, and more
complex types like arrays and objects. The data type determines the size
and format of the data stored in the variable and dictates the operations
that can be performed on it.
Value: Variables can hold a value of their assigned data type. This value
can be changed or updated during the execution of a program, allowing
the program to work with and manipulate data dynamically.
Relational Operators:
Greater than (>): Checks if the left operand is greater than the right
operand.
Less than (<): Checks if the left operand is less than the right operand.
Greater than or equal to (>=): Checks if the left operand is greater than or
equal to the right operand.
Less than or equal to (<=): Checks if the left operand is less than or equal
to the right operand.
if Statement:
if-else Statement:
The if-else statement is used when you want to execute one block of code
if a condition is true and another block if the condition is false.
else-if Ladder:
switch Statement:
The switch statement is used when you want to select one block of code
to execute from several options based on the value of an expression.
for Loop:
The for loop is used when you know the number of iterations in advance.
SYNTAX:
while Loop:
The while loop is used when you want to repeat a block of code as long
as a specific condition is true.
SYNTAX:
do-while Loop:
The do-while loop is similar to the while loop, but it guarantees that the
loop body will execute at least once because the condition is checked
after the loop body.
continue: Used to skip the rest of the current iteration and move to the
next iteration.
goto: Allows you to jump to a labeled statement within your code, but it is
generally discouraged because it can make code less readable and
harder to maintain.