You are on page 1of 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: int main() { int x, y, total; x = 10, y = 20; total = x + y; Printf (Total = %d \n, total); } where,
o o o o o

main identifier {,}, (,) delimiter int keyword x, y, total identifier main, {, }, (, ), int, x, y, total tokens

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: Comments Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminates with the characters */ Keywords The following list shows the reserved words in C. These reserved words may not be used as constant or variable or any other identifier names.

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 Char smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned depending on the implementation. unsigned char same size as char, but guaranteed to be unsigned. signed char same size as char, but guaranteed to be signed. Int basic signed integer type. At least 16 bits in size. unsigned int same as int, but unsigned. Short short signed integer type. At least 16 bits in size. unsigned short same as short, but unsigned. Long long signed integer type. At least 32 bits in size. unsigned long same as long, but unsigned. Storage size Value range

1 byte

-128 to 127 or 0 to 255

1 byte 1 byte 2 or 4 bytes 2 or 4 bytes 2 bytes 2 bytes 4 bytes 4 bytes

0 to 255 -128 to 127 -32,768 to 32,767 or 2,147,483,648 to 2,147,483,647 0 to 65,535 or 0 to 4,294,967,295 -32,768 to 32,767 0 to 65,535 -2,147,483,648 to 2,147,483,647 0 to 4,294,967,295

Floating-Point Types Following table gives you details about standard floating-point types with storage sizes and value ranges and their precision: Type Float single precision floating-point type. Actual properties unspecified (except minimum limits), however on most systems this is the IEEE 754 single-precision binary floating-point format. This format is required by the optional Annex F "IEC 60559 floating-point arithmetic". Storage size Value range Precision

4 byte

1.2E-38 to 3.4E+38

6 decimal places

Double double precision floating-point type. Actual properties unspecified (except minimum limits), however on most systems this is the IEEE 754 8 byte double-precision binary floating-point format. This format is required by the optional Annex F "IEC 60559 floating-point arithmetic". Long double extended precision floating-point type. Actual properties unspecified. Unlike types float anddouble, it can be either 80-bit floating point format, the non-IEEE "double10 byte double" or IEEE 754 quadruple-precision floatingpoint format if a higher precision format is provided, otherwise it is the same as double. See the article on long double for details.

2.3E-308 to 15 decimal 1.7E+308 places

3.4E-4932 to 1.1E+4932

19 decimal places

#include<stdio.h> Header file #include<conio.h> 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. %d to 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

You might also like