Structure

#include- will insert-header file, which is a collection of predefined functions.   

Return data type– It will tell the compiler that what kind of data (int, float, double, char, void) will be returned after the compilation of program.

Main()- It is a special functions used by C system or compiler to tell that what is the starting point of program. There can be only one main function in a program.   

/* */- This is used to comment a line to increase the understanding and readability     

{ }- defines the body in which all the functions will be written.

Input and Output

 In C to take the output on the screen we need to use predefined library function “printf” and take the input from the user “scanf”.     

Format:  

printf(“<format string>”,<list of vaiables>); 

scanf(“<format string>”,<&variable);

Compilation and Execution

  • Once you have written the program you need to type it and instruct the machine to execute it. To write a c program you need a Compiler.
  • Once it all done the compiler will convert it into the machine language (0’s and 1’s) before execution and it stores this intermediate state of execution in the object code file(.obj). After that it creates a executable file to execute the program(.exe).   
  • Executing a C Program-
    • Creating the program.
    • Compiling the program. ◦
    • Linking the program with functions that are needed from the C library. ◦
    • Executing the program.

Data Types

Data TypeSizeRange
char1 byte-128 to 127 or 0-255
Int2 byte-32768 to 32767 or 0-65535
float4 byte1.2E-38 to 3.4E+386 decimal places
double8 byte2.3E-308 to 1.7E+30815 decimal places

Libraries

  • STDIO.H
  • MATH.H
  • GRAPHIC.H
  • TIME.H
  • STDLIB.H
  • STRING.H

Variables

 A variable in simple terms is a storage place that has some memory allocated to it. Basically, a variable used to store some form of data.   

Difference b/w variable declaration and definition

The variable declaration refers to the part where a variable is first declared or introduced before its first use. A variable definition is a part where the variable is assigned a memory location and a value. Most of the time, variable declaration and definition are done together.

Keywords in C