Introduction to C-programming - The Incredible Truth

                  Introduction to C-Programming

        1.  Linking Section:
                 This section contains commands that are to be executed by the preprocessor software to combine the specified header files with the program files to enable the compiler generate the machine language code of the program.
The header files having the extension name “.h”, stores the function definitions of some functions that are used in the program which is required by compiler to generate machine language code of those functions.
E.g.- the functions ‘printf’ and ‘scanf’ are described in the header header file ‘stdio.h’ and the functions ‘clrscr’ and ‘getch’ are defined in the header file ‘conio.h’.

        2.   Program Section:
              The entire program is to be written in the main function block as otherwise compiler will not recognize the program as valid and will not generate the machine language code of the program.
A function block begins with the symbol ‘{‘ and ends with the symbol ‘}’.

[1]   Variable declaration statement:

 A statement in the program section always terminates with a semicolon (;).

Syntax:  data type _ variable name

A variable can be defined as a symbol that represents a memory space where data taken from user can be stored and used in the program, seems the data stored in the variable changes during program execution, hence the name variable which means a thing that changes and is not a constant.

  Variables are of two types-

(i)                  Signed variable, where both positive and negative data can be stored and by default variable is a signed variable.
(ii)                Unsigned variable, where the data stored is always positive.

The data type of a variable determines what type of data will be stored in the variable and how much memory space will be required to store data in the memory space represented by the variable.

                 Data type
                Memory Space
1 byte (8 bits)
2 byte (16 bits)
4 byte (32 bits)
Large fractional
8 byte (64 bits)

2]   Data input statement:

The ‘scanf’ function is used to take data from user as inputs and store it in the variable.

Syntax of ‘scanf’ function is-
scanf (“Control string “, &v1, &v2, &v3, ….., &vn);

Where, &v1 = address of variable v1

         Data type
        Control string
Character (Single)
Character (multiple)

[3]    Data output statement:

The ‘printf’ function used to display data as output. The syntax for the ‘printf’ function is –

printf(“Control string”, v1, v2, v3, ……, vn);

The control string is same as for ‘scanf’.

See Also:
Addition of two numbers with C coding

Simple C-Programming examples


Popular Posts