Professional Documents
Culture Documents
Chapter - 2
Chapter - 2
UNIT – 2
Example
const int x = 10 ;
Here, 'x' is a integer constant with fixed value 10.
Example:
#define PI 3.14
Here, PI is a constant with value 3.14
Chapter
Chapter – 2 : Algorithms
– 2 : Constants, Variables
and&Flowcharts
Data Types in ‘C’
Datatypes
Datatype is a set of value with predefined characteristics.
Datatypes are used to declare variable, constants, arrays, pointers and
functions.
The memory size and type of value of a variable are determined by
varible datatype.
double
Both float and double are similar but differ in number of decimal
places.
float value contains 6 decimal places.
double value contains 15 or 19 decimal places.
The following table provides complete details about floating point
datatypes.
value:
#define CNAME value
The value of the constant.
OR
#define CNAME (expression)
CNAME: expression:
The name of the constant. Expression whose value is
Most C programmers define assigned to the constant.
their constant names in The expression must be
uppercase, but it is not a enclosed in parentheses if it
requirement of the C contains operators.
Language.
Chapter – 2 : Constants, Variables & Data Types in ‘C’
#define Directive - Example
#include <stdio.h>
int main()
{
printf("%s is established in year %d\n", NAME, YEAR);
return 0;
}
Structures
Unions
Enumeration