C Basics
C Basics
Basics
Basics of C Programming?
1
General Structure of a C Program
/* Documentation */
Pre-Processing Statements
Global Declarations
Main method
Documentation /* Documentation */
- It is used to provide brief information Pre-Processing Statements
of the program. Global Declarations
3
General Structure of a C Program
Pre-Processing Statements
- It is used to link the header files, /* Documentation */
define the constants, etc... Pre-Processing Statements
Global Declarations
7
General Structure of a C Program
Userdefined Methods
- In this section of the program we write the /* Documentation */
actual code for the userdefined methods. Pre-Processing Statements
- Userdefined methods can be implemented Global Declarations
either before or after the method.
Main method
- If it is implemented after the main then it
must be declared either inside or before the
main method. Used defined methods
implementation
- If it is implemented before the main then the
declaration can be ignored.
8
General Structure of a C Program - Example
/* Program to print a message Hello World! */
#include<stdio.h>
void main()
{
printf(“Hello World!!!!”);
9
Rules for Writing C programs
Every c program must contain exact one main
method
Every executable instruction must end with
semicolon (;)
All the system defined words (Keywords) must
be used in lowercase letters
Every open brace ({) must have the respective
closing brace (})
The variables must be declared in the
declaration section before they are used 10