Skip to main content

STRUCTURE OF A “C” PROGRAM


STRUCTURE OF A “C” PROGRAM:

The general structure of a C programming language is sub-divided into different sections. Those are
1. Documentation Section
2. Pre-processor Directive Section
a. Linkage Section
b. Definition Section
3. Global Variable Declaration Section
4. Main function
5. Local Variable Declaration Section
6. Executable Part
7. User Defined Section

DOCUMENTATION SECTION:
Documentation section is also known as comment section. Here, comment statements are non-executable statements. Comments are started by using “/*” and end with “*/”. Comments are used for the purpose of documentation within the program. There are two types of comments. Single line comments and multi line comments.

Ex:          /* My First Program */                                     // My First Program

PREPROCESSOR DIRECTIVE SECTION:

 In C language “#“ is called as pre-processor directive, it is defined as to do something before compiling the program. These are divided into two sections.
1.      LINK SECTION
Link section is used to include the header files, which contains definition for the standard library functions provided by C developers.
Ex: # include<stdio.h>
2.      DEFINITION SECTION
By using this we can define constant variables with its values.
Ex: # define PI 3.141

GLOBAL VARIABLE DECLARATION:
If you want to use a variable throughout the program, you need to declare variable as Global variable. Global variables are declared outside the main function. Global variables are automatically initialized with zero.

MAIN FUNCTION
main() is the important section in every C program. We cannot write programs without main() function. Execution starts from main() function. End of the main() function represents end of the program execution.

LOCAL VARIABLE DECLARATION:
Variables which are used in main() program are declared by using local variable declaration statement. These variables are available within the block only.

EXECUTABLE PART:
This section has reading, writing and processing statements having input or output functions, library functions, formulas, control statements.

USER DEFINED SECTION:
In this section we define functions called sub-programs which are called by calling statements from main() section. Every sub-program or function has local variable statements and executable statements similar to the main() program.

Ex: function or sub-program
              {
                 Statements;
              }

Example Program on C-structure:

/* Write a C Program to print Hai */

#include<stdio.h>
main()
          {
            printf(“Hai”);
            return 0;
         }


























Comments

  1. Computer Information - Computer Mobile Information is one of the leading computer and mobile, Internet, software and hardware knowledge providing website. You will get up to date information about computer and mobile free of cost. We also provide software and hardware solutions and services online free of cost. For more visit: Computermobile.info

    ReplyDelete
  2. Learn computer by knowing the merits and demerits of computer
    Demerits of computer

    merits of computer

    ReplyDelete

Post a Comment

Popular posts from this blog

Characteristics of computers

    Characteristics:        All computers have similar characteristics, which tells how computers are efficient to perform task. Computers have some Limitations also. Speed:     Computer can work very fast. It takes only few seconds for calculations on very large amount of data. Computer can perform millions (1,000,000) of instructions per second.      We measure the speed of computer in terms of microsecond (10-6 part of a second) or nanosecond (10 to the power -9 part of a second).   Accuracy:        The degree of accuracy of computer is very high and every calculation is performed with the same accuracy.  The errors in computer are due to human and inaccurate data.       The calculation done by computer are 100% error free, If we provide accurate input. Diligence:        A computer is free from tiredness, lack of concentration...

DS LAB FOR II YEAR

1.SINGLE LINKED LIST Procedure for creation of single linked list: STEP-1 : Declaring a variable named as “item”.Ie the element what we place in the linkedlist of the new node.         STEP-2 : Read the value   in “item”. Set first=last=null and next=null. STEP-3: Create a new node named as temp and assign the variable item to data part andassign Address of the node temp to null.       temp.data=item;       temp.next=null; STEP-4: Check   the address part of the first node Check if first=null Then assign first=last=temp Other wise Then assign the new node tolast.next=temp          last=temp STEP-6 : Repeat STEP-3 until you read required nodes. Procedure for display the linked list: STEP-1 : Check whether the list having nodes or not i.e Check if first=null        ...

LEVELS AND CURVES

LEVELS:                 Levels are used to set the shadows, mid tone etc.  O pen an image on Photoshop window. Select image menu on menu bar than adjustments than levels. A dialogue box will appear on screen which shows three pointers which indicates three optimum. The black triangle indicates shadows and gray triangle indicates mid tone and white triangle indicates highlights. In the channel menu different options are provided in drop down list. Make sure select on preview, which gives current adjustments on your picture. CURVES: Curves are to  similar to levels, it gives more power to control shadows highlights and mid tones. One of the simplest adjustment we can make with curves is increasing the contrast. Go to image menu and than adjustments,than curves. Dialogue box will appear on screen with straight diagonal line.      ...