New Technology | New Mobiles | Job Notifications | Admissions | Hall tickets | Results | Shopping Offers | Learning Computer Skills

Monday, September 10, 2018

INTRODUCTION OF C LANGUAGE | HISTORY OF C | STRUCTURE OF C

C LANGUAGE

C LANGUAGE

INTRODUCTION: 
C Language is  a general purpose structured programming language. It instructions consist of terms that resemble algebraic expressions, argument by certain English keywords such as if, else, for, do, while and etc. In this respect C resembles other high level structured programming language such as Pascal and FORTRAN. C also contains certain additional features, however that allow it to be used at a lower level, thus bridging the gap between machine language and the more conventional high level languages.

History of C : 

C was developed in the 1970's by Ritchie at Bell Telephone laboratories. It is an outgrowth of two earlier language, called BCPL  and B, which were also developed at Bell Laboratories. C was largely confined to use within Bell Laboratories until 1978, when Brain Kernighan and Ritchie published a definitive description of the C - language.

Structure of a C Program:

Every C program consists of one or more functions, one of which must be called main. The program will always begin by executing the main function. Additional function definitions may precede or follow main.

Each function must contain:

  • A function heading, which consists of the function name, followed by an optional list of arguments enclosed in parentheses.
  • A list of argument declarations, if arguments are include in the heading.
  • A compound statement, which comprises the remainder of the function


The arguments are symbols that represent information being passed between the function and other parts of the program.(Arguments are also referred to as parameters.)

Each compound statement is enclosed within a pair of braces, i.e. { and }. The braces may contain combinations of elementary statements (called expression statements) and other compound statements. Thus, compound statements may be nested, one within another. Each expression statement must end with a semicolon (;).Comment (remarks) may appear anywhere within a program, as long as they are placed within the delimiters /* and / (E.g.: /* this is a comment */ ). Such Comments are helpful in identifying the program’s principal features or in explaining the underlying logic of various program features.

Example 1: Simple Program
#include<stdio.h>                          /* LIBRARY FILE ACCESS */
/* program to print  name */          /* TITLE (COMMENT) */
void main( )                                  /* FUNCTION HEADING*/
{
printf("Asha");                              /* OUTPUT STATEMENT*/
}

The program in exmple 1 prints the following message on your screen:
Asha

The program illustrated in example 1 consists of steps given below:


  • #include… statement. 
  • Declaration of the main function. 
  • Processing statement 

All these steps have been discussed below.

#include… statement: 

#include… statement are the first statements in any C program. They are the most fundamental set of instructions, which is required for writing any C program. The hash notation (#) at the beginning of the include… statement indicates that the following instruction is a special instruction to the C Language. The #include… statement establishes a reference to the header file (as indicated by the extension .h). It is specified in the brackets ‘<>’ following the #include… statement and is processed prior any other processing taking place. It is referred to as a preprocessor directive. In the Example 1 above, the header file being referred to is stdio.h (Standard Input Output Header file).

Declaration of the main function: 

A program consists of single function main( ). A function is a self-contained block of code that is referenced by a name, main in this case. There may be a lot of other code in a program, but every C program consists of at least the function main( ), and there can be only one function main within a program. Execution of a C program always starts with the first statement in main( ). The word main is followed by parentheses ‘( )’.

Processing statement: 

In Example 1, function main( ) contains one executable statement:
printf("Asha");

This excuted in sequence, starting at the beginning. In general, the statements in a function are always executed sequentially, unless these are a statement that specifically alters, the sequence of execution.

Output data can be written from the computer into a standard output device using the library function 'printf'.
Share:

0 comments:

Post a Comment

Powered by Blogger.

Search This Blog

Recent Posts

Unordered List

Pages

Theme Support