The document discusses various data types in C including integer, floating point, character and void types. It notes the memory size and value ranges of basic types like char, short, int, float, double and long double. It also describes void as a data type used for functions without return values or arguments. The document then covers keywords, input/output functions like scanf() and printf(), and format specifiers used to define variable types for input and output.
2. DATA TYPES
• Data types in c 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.
3. BASIC DATA TYPES
• The basic data types are integer-based and floating-point based. C
language supports both signed and unsigned literals.
Data Types Memory
Size
unsigned signed
char 1 byte 0 to 255 −128 to 127
short 2 byte 0 to 65,535 -32,768 to 32,767
int 2 byte 0 to 65,535 −32,768 to 32,767
float 4 byte 1.2E-38 to 3.4E+38
double 8 byte 2.3E-308 to 1.7E+308
long double 10 byte 3.4E-4932 to 1.1E+4932
4. VOID DATA TYPES
• The void type specifies that no value is available. It is used in three
kinds of situations −
• Function returns as void: A function with no return value has the
return type as void. For example, void exit (int status);
• Function arguments as void: A function with no parameter can
accept a void. For example, int rand(void);
• Pointers to void: A pointer of type void * represents the address of an
object, but not its type. For example, a memory allocation
function void *malloc( size_t size ); returns a pointer to void which
can be casted to any data type.
5. KEYWORDS
• A keyword is a reserved word. You cannot use it as a variable name,
constant name, etc. There are only 32 reserved words (keywords) in
the C language.
6. INPUT AND OUTPUT
• C language has standard libraries that allow input and output in a
program.
• The stdio.h or standard input output library in C that has methods for
input and output.
• scanf(): The scanf() method, in C, reads the value from the console as per
the type specified. Syntax:
scanf(“%X”, &variableOfXType);
• printf(): The printf() method, in C, prints the value passed as the
parameter to it, on the console screen. Syntax:
printf(“%X”, variableOfXType);
7. FORMAT SPECIFIERS
• The format specifiers are used in
C for input and output purposes.
• Using this concept the compiler
can understand that what type of
data is in a variable during taking
input using the scanf() function
and printing using printf()
function.
Format Specifier Type
%c Character
%d Signed integer
%f Float values
%l or %ld or %li Long
%lf Double
%s String
%p Pointer