Data Types in C/C++
C/C++ supports many data types. Out of all of these three are main.
i) Integer
ii) Float
iii) Character
i) Integer
Integer data type is used used to store simple numeric values which excludes decimal point. it is a 16 bit data type.
Integer is of two types signed and unsigned integer
In signed mode it can store values ranging from -32768 to 32767. the keyword used to create signed integers is int the type specifier for signed integer is %d
In un-singed mode it can store values ranging from 0 to 65535. the keyword used to create unsigned integers is unsigned int. The type specifier for signed integer is %u.
ii) Float
Float data type is used to store simple numeric values but with decimal point only. it is 32 bit data type. Type specifier for Flaot variable is %f. The keyword used to create float variables is float
iii) Character
Character variables are used to store single single character at a time. The keyword used to create Character type variables is char. Type specifier for character type variable is %c.
Some Examples of Integer, Float and Character type variable declaration
int a;
int a,b,c;
int year,years,cou,n;
float amt,length,bredth;
float amount,roi;
char ch;
char em;
Assignment statement
Assignment statement is used to store values in variables. General syntex for assignment statement is
variable = variable | constant | expression
i.e.
a=10;
b=20;
c=a+b;
d=c;
No comments:
Post a Comment