Wednesday 1 October 2014

Conversion Specification and intro input/output

Input data , process data , and output process data. there are three main function of any program. The input operation involve movement of data moves from an input device (like keyboard) to computer memory, while in output operation the data moves from computer memory to the output device (monitor).  
     C language does not provide any facility for input/output operations. The input and output operation perform through a library function that are used by compiler. we will discus library function in the potion of Function. in short, "library function is the predefine function, which is written by programmer, only we call that function and use in the program". before using library function in the program. we must include header file in the program, in which specific function is stored. for example: for input and output operations we include header file <stdio.h> "stdio" stands for standard input output operation and .h stands for header file. all input output operation perform through this function. Scanf(); and printf() is the member of stdio.h library function. how to take input and output data in C language, we must know what is Conversion Specification.

Conversion Specification

The function scanf( ) and printf( ) make use of conversion specification to specify the type and size of data. Conversion specification is the way that specify and control input and output data. data type size and type depend on this. Each conversion specification must begin with a percent sign(%). some conversion specification give below-
%c              -     read/output a single character.
%d                    read/output integer value.
%f                     read/output floating point number.
%e                    read/output floating point number
%lf                    read/output long rang of float.
%h                    for short integer.
%o                    for octal integer.
%u                    an unsigned integer.

for eg. to read data .

sacnf("%d",&a);

in above example %d specify that the input data is integer that is stored in variable 'a'. & is used for address, with variable it create a memory location for variable, depend on data type. we declare float type variable then & create 4 byte on memory for variable. if we declare integer type variable then it create 2 byte memory.


No comments:

Post a Comment