Basic of C programming language and History

22 Jul 2022 Balmiki Mandal 0 C Programming

Learn the Basics and History of C Programming Language

Dennis Ritchie developed the C programming language in 1970 at Bell laboratories. Initially, it Was designed for Programming in the Operating System called UNIX.  After the advent of C,  The whole UNIX operating system Was rewritten using it. now almost the entire  Unix operating system and the Tools supplied with it including the C compiler itself are Written in C.

 

Advantages of C-Programming:

  • C is Middle-level Language (The Middle-level languages are somewhere between the low-level machine understandable assembly languages and high-level user-friendly languages)
  • C reduces the gap between low-level and high-level languages
  • it can be used for writing operating systems as well as doing application-level language.
  • Help to understand the fundamentals of computer theories  (in the modern high-level language, the machine-level details are hidden from the user, so in order to work with  CPU cache)  memory, and network adapter, learning c programming is a must)
  • Fewer libraries (c programming language has fewer libraries in comparison with other high-level languages so learning c programming also clears programming a lot of things from scratch)
  • C is very fast in terms of execution time (programs write a compiled in execute much faster than compared to any other programming languages.)
  • C programming language is very fast in terms of execution as it does not have only additional processing overhead such as garbage collector or preventing memory leaks.
  • The programmer must take care of these things on his own.


What are the characteristics of the C programming language?

It is a Middle-level Language .it has the simplicity of a High-level language as well as the power of a low-level language. This aspect of C makes it suitable for writing both application programs and system programs. Hence it is an Excellent, Efficient, and general-purpose language for most the applications such as Mathematical, scientific, business, and system software applications.

C is a small language, Consisting of 32 English words known as keywords(if..else, break, etc). The power of C is augmented by the library function provided with it.  the language is extendible since it allows the users to add 
own library to the library. 

C Contains Control constructs needed to write a structured program hence it is considered a structured programming language.  it includes structures for selection (if...else, switch), reception(while for, do...while), and exit(break).

The program written in C are Portable i.e. programs written for one type of computer or operating system can be run on another type of computer or operating system.


Structure of c Programming language.

A c-program is a collection of one or more functions. every function is a collection of statements and performs some specific task. the general structure of c programs is-

1. /*    comments   */
2. preprocessor directives
3. Global Variable 
4. main() function
{

5. local variables statements

}

function1()
{
local variable  statements
}


1. comments: comments can be placed anywhere in a program and are enclosed between the delimiters / * and */ comments are generally used for documentation purposes.

2. preprocessor Directive: preprocessor Directives are processed through the preprocessor before the c Source code passes through the compiler. The commonly used preprocessor directives are #include and #define.

  • #include is used for including header files.
  • #define is used to define symbolic constants and macros.

Every C program has one or more functions. if a program has only one function then it must be main(). Execution of every c program starts with the main() function.it has two parts, declaration of local variables and statements. the scope of the local variable is local to that function only. statements in the main() function are executed one by one. other functions are the user-defined functions, which are possible

3. Global Variable: A Variable declared as global is called a global variable 

4. main() function: A main function refers to where the program execution is start is called the main function

5.  local variables statements: A variable declared as local (within the function) is called a local variable.
 


Compilation and Execution of c Programming 

There are four compilation stages are there in c programming 

  1. Preprocessor 
  2. Translator 
  3. Assembler 
  4. Linker

Click here to know more 

 

Error in a C program: Error is an illegal operation that occurs in the compiler which results in abnormal work of the program 

There are two types of error 

  1. Compile time error 
  2. run time error

Click here to know more about error 

 

Environments of c Programming: There are three Environments of  c

  1. Program Creation
  2. program compilation
  3. program execution

Linux\unix Enviroment

Basically, a command line C compiler is provided with the Linux\unix Operating system. The compiler is named CC or GCC

1. program Creation:

In the Linux \ Unix environment, files can be created with the vi editor 

$ vi file_name.c

2. Program compilation

After the Creation of the c program, it can be compiled 

$ cc file_name.c

3. program execution

after the compilation of the program, it can be executed as

$ .\a.out 

 

Ms-DOS Environment

in an MS-DOS environment creation, compilation and Execution can be done using IDE (Integrated Development Environment).

1. Program creation

 The program file can be created using any Editor and should be saved with .c Extension

2. Program compilation 

after saving the file, the C program can be compiled at DOS prompt by writing 

tcc file_namre (in Turbo C)

3. Program Execution

After the Compilation of the C program, the executable file filename.exe is created. it is Executed at DOS prompt by writing

C:\> filename 

 

 

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.