INTRODUCTION TO C

No Comment - Post a comment


INTRODUCTION:

C is a programming language developed by Dennis Ritchie. It is developed from a programming language called B. The B is developed from an older language known as BCPL (Basic combined programming language). There are two C version known as C89 and C99.

FEATURES OF ‘C’ LANGUAGE:

C language is a middle level programming language.
C language is portable i.e. the software that is created using C language for one operating system can also able to run in other operating system with little or no modification.
C language is also as called as structured programming language because it supports various looping statements like Do while, for, while (Discussed later). As C is a structured programming it doesn’t encourages the use of goto statement.
C language is not case sensitive ie. Upper and lower case characters are different. For example, NAME and name are different in C.

COMPILATION AND LINKING:

The computer can able to understand only 0’s and 1’s.Hence the C statements (source code) should be converted to 0’s and 1’s (Machine level language) before execution. This process is done by programs known as compiler and interpreter.

Compiler and interpreter:

The compiler is a program that reads the entire C program at a stretch and converts it to object code(binary code or machine code).

Interpreter is a program that reads the statements in a C program line by line and converts it to object code.

The object code generated after compilation is linked with standard C library
Functions by using linker.

KEYWORDS IN C LANGUAGE:

Keywords in ‘C’ have predefined special meanings. There are nearly 32 keywords in ‘C’ programming language. They are:

auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
In c language else is a keyword but not ELSE.
GENERAL STRUCTURE OF A ‘C’ PROGRAM

The ‘C’ program has different section namely

1. HEADER FILE SECTION:

The header file is specified in this section. The header file contains the prototype for the various in-built functions.

2. GLOBAL VARIABLE SECTION:

This section contains the declaration of the global variables.These global variables are accessed by all the functions in a program.

3. MAIN FUNCTION:

All programs should have one main function. The execution of a program starts from a main function only. All the function is defined as

General syntax:

Return-type function-name (parameter list)
{
Set of statements;
}

While giving function definition it is necessary to specify the data type of the value that the function is going to return. The return type is followed by the function name which may the main or any other name ie.user-defined name.

The list of parameter that it is going to get from the calling function (discussed later) should also be specified.

It is then followed by the curly brace which indicates the start of a function. It includes set of statements. A statement in ‘C’ terminates with a semicolon (;).

The statement can be declaration of the local variable (the variables that are accessed only by the function which it is declared).It also contains executable statement. The function ends with a curly brace.

Header file section

Global variable declarations

int main(parameter list)
{
Set of statements;
}

return-type function1(parameter list)
{
Set of statements;
}


return-type function2(parameter list)
{
Set of statements;
}
.
.
.
return-type functionN(parameter list)
{
Set of statements;
}

 
This Post has No Comment Add your own!

Post a Comment