Skip to main content

Basic Structure of 'C' Program and Printing Hello,World! in 'C'

The Basic Structure of ‘c’

Like most of the programming languages, C too has a structural approach and hence it has a basic structure.

Here is the basic structure of a typical C program:

1)    DOCUMENTATION
A Typical Program consist s of Documentation, in which the Details regarding the program and the programmer are written in comments.

2)   HEADER FILES: LINK TO THE C LIBRARY
Header Files links the Various Library modules, classes to the program,
Header files Includes methods from C Library with a “#include” command and the function name within < > symbols.
E.g.: include<stdio.h> which includes Standard Input Output Methods to C Program.

3)   DEFINITION
define directive is used to define a variable whose value stays same throughout the program.
E.g.:  #define PI 3.14

4)  GLOBAL DECLARATIONS
The Functions other than main () are declared here in global declaration section
E.g.:  int xyz (int)

5)   MAIN FUNCTION WITH RETURN TYPE
The main function is where the execution of the program starts. The return-type is used to decide whether the function would return a value or not.
¨   Within main (), scope delimiters are used which decides the scope of a program and the body of the programs i.e. statements to be executed are written.
Example:
void main ()
{
//statement of main function
}

Comments

Popular posts from this blog

Iteration and Iterative statements.

ITERATION IN C According to Google: Iteration is the repetition of a process or utterance. In a programming language Iteration stands for a repeating execution of a set of codes until desired condition is obtained. Iteration is done through Iterative Statements. Iteration is also called Looping, which means doing a work again and again. For better understanding of a loop, here is a Real world filmy example: Remember the climax scene from Dr. Strange (2016) where Dr. Strange goes into space to bargain for Earth’s protection from Dormammu, in order to do so he starts an endless time loop which he won’t stop until dormammu accepts his demands and when Dormammu did so the loop stopped. Iteration works in same way, considering his approach as loop’s condition. There are three Iterative statements which makes Iteration possible: For statements (loops).   While statements (loops).   Do-while statements (loops). FOR LOOP AND WHILE LOOP: T...