Examples ?
Integer Data Type
The integer datatype in C is used to store the integer numbers(any number including positive, negative and
zero without decimal part). Octal values, hexadecimal values, and decimal values can be stored in int data type
in C.
Range: -2,147,483,648 to 2,147,483,647(the max & minimum values that can be stored in a variable of a
datatype)
Size: 4 bytes
Format Specifier: %d
The integer data type can also be used as
1. unsigned int: Unsigned int data type in C is used to store the data values from zero to positive
numbers but it can’t store negative values like signed int.
2. short int: It is lesser in size than the int by 2 bytes so can only store values from -32,768 to 32,767.
3. long int: Larger version of the int datatype so can store values greater than int.
4. unsigned short int: Similar in relationship with short int as unsigned int with int.
Character Data Type
Character data type allows its variable to store only a single character. The size of the character is 1 byte. It is
the most basic data type in C.
Range: (-128 to 127) or (0 to 255)
Size: 1 byte
Format Specifier: %c
Float Data Type
,In C programming float data type is used to store floating-point values. Float in C is used to store decimal and
exponential values. It is used to store decimal numbers (numbers with floating point values) with single
precision.
Range: 1.2E-38 to 3.4E+38
Size: 4 bytes
Format Specifier: %f
2.What is an Algorithm? Explain the characteristics of
algorithm with example?
An algorithm is a step-by-step process, or a set of rules designed to perform a specific task or solve a
particular problem. Algorithms serve as a blueprint for writing code, guiding the program through a
sequence of operations to achieve a desired outcome.
Characteristics of an Algorithm:
Input: The algorithm takes zero or more inputs.
Output: The algorithm produces one or more outputs.
Definiteness: Each step of the algorithm is clear and unambiguous.
Finiteness: The algorithm must terminate after a finite number of steps.
Effectiveness: Each step of the algorithm is basic enough to be performed, ideally by a computer
Examples:
Algorithm-1: Addition of Two Numbers
1. Start
2. Input: Read two numbers, num1 and num2.
, 3. Process: Calculate the sum of the two numbers by performing the operation: sum =
num1 + num2
4. Output: Display or return the result, sum.
5. End
3) Explain Relational and logical Operators with Suitable
Examples ?
Relational Operators:Relational operators are used to compare two values. The result of the comparison is
either true or false.
The following table give the list of relational operators :
Operator Meaning
> Greater than
< Less than
== Equal to
!= not equal to
<= less than or equal to
>= greater than or equal to
Let a=9, b=5 then the operations with relational operators are listed below.
Expression Result
a>b 1
a<b 0
a==b 0
a!=b 1
a<=b 0
a>=b 1
output: