syntax and data types in c language
TRANSCRIPT
-
8/13/2019 Syntax and Data Types in C Language
1/5
Syntax and Data Types in C Language
A C program consists of various tokens and a token is either a keyword, an identifier, a constant,
a string literal, or a symbol. For example, the following C statement consists of five tokens:
C tokens example program:
where,
o mainidentifiero {,}, (,)delimitero intkeywordo x, y, totalidentifiero main, {, }, (, ), int, x, y, totaltokens
Semicolons ;
In C program, the semicolon is a statement terminator. That is, each individual statement
must be ended with a semicolon. It indicates the end of one
two different statements:
CommentsComments are like helping text in your C program and they are ignored by the compiler. They
start with /* and terminates with the characters */
KeywordsThe following list shows the reserved words in C. These reserved words may not be used asconstant or variable or any other identifier names.
int main(){
int x, y, total;
x = 10, y = 20;
total = x + y;Printf (Total = %d \n, total);
}
-
8/13/2019 Syntax and Data Types in C Language
2/5
A delimiter
is a unique character or series of characters that indicates the beginning or end of a specific statement,
string or function body set.
Data Types:
In the C programming language, data types refer to an extensive system used for declaring variables
or functions of different types. The type of a variable determines how much space it occupies in
storage and how the bit pattern stored is interpreted.
Integer Types
Following table gives you details about standard integer types with its storage sizes and value ranges:
Type Storagesize
Value range
Charsmallest addressable unit of the machine that cancontain basic character set. It is an integer type.Actual type can be either signed or unsigneddepending on the implementation.
1 byte-128 to 127 or 0 to255
unsigned charsame size as char, but guaranteed to be unsigned.
1 byte 0 to 255
signed charsame size as char, but guaranteed to be signed. 1 byte -128 to 127
Intbasic signed integer type. At least 16 bits in size.
2 or 4bytes
-32,768 to 32,767 or -2,147,483,648 to2,147,483,647
unsigned intsame as int, but unsigned.
2 or 4bytes
0 to 65,535 or 0 to4,294,967,295
Shortshortsigned integer type. At least 16 bits in size.
2 bytes -32,768 to 32,767
unsigned shortsame as short, but unsigned. 2 bytes 0 to 65,535
Longlongsigned integer type. At least 32 bits in size.
4 bytes-2,147,483,648 to2,147,483,647
unsigned longsame as long, but unsigned.
4 bytes 0 to 4,294,967,295
-
8/13/2019 Syntax and Data Types in C Language
3/5
Floating-Point Types
Following table gives you details about standard floating-point types with storage sizes and valueranges and their precision:
TypeStorage
sizeValuerange
Precision
Floatsingle precision floating-point type. Actualproperties unspecified (except minimum limits),however on most systems this is theIEEE 754single-precision binary floating-point format.Thisformat is required by the optional Annex F "IEC60559 floating-point arithmetic".
4 byte1.2E-38 to3.4E+38
6 decimalplaces
Doubledouble precision floating-point type. Actualproperties unspecified (except minimum limits),however on most systems this is theIEEE 754double-precision binary floating-point format.Thisformat is required by the optional Annex F "IEC60559 floating-point arithmetic".
8 byte2.3E-308 to1.7E+308
15 decimalplaces
Long doubleextended precision floating-point type. Actualproperties unspecified. Unliketypes float anddouble, it can be either80-bitfloating point format,the non-IEEE "double-double" orIEEE 754 quadruple-precision floating-point format if a higher precision format isprovided, otherwise it is the same as double.Seethe article on long double for details.
10 byte3.4E-4932to1.1E+4932
19 decimalplaces
http://en.wikipedia.org/wiki/Single-precision_floating-point_formathttp://en.wikipedia.org/wiki/Single-precision_floating-point_formathttp://en.wikipedia.org/wiki/Double-precision_floating-point_formathttp://en.wikipedia.org/wiki/Double-precision_floating-point_formathttp://en.wikipedia.org/wiki/Extended_precisionhttp://en.wikipedia.org/wiki/Extended_precisionhttp://en.wikipedia.org/wiki/Quadruple-precision_floating-point_formathttp://en.wikipedia.org/wiki/Quadruple-precision_floating-point_formathttp://en.wikipedia.org/wiki/Long_doublehttp://en.wikipedia.org/wiki/Long_doublehttp://en.wikipedia.org/wiki/Quadruple-precision_floating-point_formathttp://en.wikipedia.org/wiki/Quadruple-precision_floating-point_formathttp://en.wikipedia.org/wiki/Extended_precisionhttp://en.wikipedia.org/wiki/Extended_precisionhttp://en.wikipedia.org/wiki/Double-precision_floating-point_formathttp://en.wikipedia.org/wiki/Double-precision_floating-point_formathttp://en.wikipedia.org/wiki/Single-precision_floating-point_formathttp://en.wikipedia.org/wiki/Single-precision_floating-point_format -
8/13/2019 Syntax and Data Types in C Language
4/5
-
8/13/2019 Syntax and Data Types in C Language
5/5
#include Header file
#include Second Header File. Supports the different functions like
getch(), clrscr() etc...
Int main () Main Function
{Int a,b,c; The Declaration of variable
Clrscr(); To clear the screen when new output is generated
Printf(Enter first number:\n);To print text on screen
Scanf(%d, &a); data is stored. %dto display the integer
Printf(Enter second number:\n);
Scanf(%d,&b);
C=a+b;
Printf(The Sum of %d and %d is %d,a,b,c);
Getch();Return 0;
}
In JAVA