C is neither a high level language nor a low level language. It is very close to the machine architecture but independent of it and at the same time, does not compromise its ease of use. Hence, C is often called as a 'middle level language'. Going in the same line, C is also considered as a pure "System programming Language". C is also called as structured high level programming language. The most important of a structure programming language is that it uses blocks. A block is a set of statements that are logically connected. A structure programming language also supports loop structure, such as do-while, for constructs, and so on. A structured programming language also allows compiling function separately and can be accessed by any program.
Be it tools like compilers, operating system kernels, system utility tools, c is the foremost language that comes to a programmer's mind. it is quite amazing to know that very popular operating systems like UNIX and Windows are entirely written in C. So, if you are learning C today, may be tomorrow, you would be writing an operating system for the fifth generation computers.
Remember that C is not a very big language. It is a compact language with a very small yet powerful set of operators. The design of the language makes sure that these operators are used most optimally.
History of C
The C programming language was developed by Dennis Ritchie at Bell Telephone Laboratories in 1972. After 1980's numerous compilers and interpreters had been written for all sizes of computers, so the popularity fo C language has become widespread.
C is also called a middle level computer language because it combines elements of a high level language with some features of assembler. A high level language tries to give programmer everything through built-in functions in the language. A low level language forces programmers to define function directly from the user leve.
As a middle level language, C language manipulates bits, bytes and addresses. Program written in one type of computer can be used in another machine with single modification.
Features and Importance of C
- It contains powerful data definition method. The data types supported are alphanumeric characters, character string, integer numbers and floating point numbers.
- It contains a powerful instructions set of data operators that tell computer how to manipulate the data within a program.
- It contains the modern method of coding loops.
Advantages and Disadvantages of C
Advantages- C is one the efficient programming language. Using this language, operating system like windows and UNIX were developed.
- There is no limitation while programming using C. We can develop any kinds of program.
- Compiler of C language is very efficient then any other language and the code generated by C compiler is much light weighted than any other languages.
- C is powerful language and the use of pointer had made it unique.
In fact, C language has very less disadvantages but still there are some as following,
- C on the other hand is complex and it is difficult of the beginners.
- As said earlier, pointer is one of the unique features which have made C powerful but if it is mishandled the system may crash so it is risky too.
- The modern concept of Object Oriented programming is not available in C.
- C language mostly focuses on structures and procedures and not to data like in real world situation.
Download C Compiler
Turbo C++ | Click Here To Download |Dev C++ | Click Here To Download |
Structure of C Program
The best way to learn any programming language is by writing programs in the language. Let us start by writing the first program in C.1 2 3 4 5 6 | /* This is our first program in C */ #include<stdio.h> main(){ printf("Hello World"); printf("\n Welcome to C Programming"); } |
Output
Hello World
Welcome to C Programming
Welcome to C Programming
The line numbers in the program does not form a part of the source code. The description of the source code is as follows:
- Starting with /* and ending with */ are comments in C and it is not a part of the source code. It is not executed by the compiler.
- #include<stdio.h> is a pre-processor directive which includes the header file <stdio.h> into the source code. stdio.h means standard input output header file.
- main() is a function. The execution of the program begins with this function. It is called by the operating system of the computer and other functions of a program is called by main() function.
- { and } indicates the beginning and ending of a block of code.
- printf() is an output function in <stdio.h> which displays the output on the console screen. Note that the statements in C is ended using a semicolon;
Compiling process
The main aim of using compiler is to transform a program written in a high level programming language from source code into object code. Programmers write programs in a form called source code. Source code must go through several steps before it becomes an executable program.
The first step is to pas the source code through a compiler, which translates the high level language instructions into object code. The final step in producing an executable program, after the compiler has produced object code, is to pass the object code through a linker. The linker combines modules and gives real values to all symbolic addresses.
Every high level programming language comes with a compiler. In effect, the compiler is the language, because it defines which instructions are acceptable.
Because compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. For example, there is a FORTAN compiler for PCs and another for Apple Macintosh computers. In addition to that compiler industry is quite competitive, so there are actually many compilers for each language on each type of computer. More than a dozen companies develop and sell C compilers for the computers.
Turbo C, Borland C, Dev C etc. comes with its own inbuilt compiler or user can choose his/her compiler. After typing the above code in a text file and save it as first.c. In Turbo c compiler, key F9 compiles the program and ctrl + F9 compiles and runs the program. Compiling first.c, would generate the following output.
Hello World
Welcome to C Programming
Welcome to C Programming
After compilation, the compiler would generate an .exe (executable file) which would run your program on the system and give the desired result.
Header Files in Standard Library
Header files generally are a collection of macros, types, functions and constants. They do not have a main() function. They cannot be executed as such. Any program that needs those functions can include the corresponding header files. The functions, macros and types are declared in various header files of the standard library.Header Files | Purpose | Functions declared |
---|---|---|
stdio.h> | Used for standard Input and Output (I/O) operations. | printf(), scanf(), getchar(), putchar(), gets(), puts(), getc(), putc(), fopen(), fclose(), feof() |
conio.h | Contains declaration for console I/O functions. | clrscr(), exit() |
ctype.h | Used for character-heading or testing characters | isupper(), islower(), isalpha() |
math.h | Declares mathematical functions and macros. | pow(), sqrt(), cos(), tan(), sin(), log() |
stdlib.h | Used for number conversions, storage allocations. | rand(), srand() |
string.h | Used for manipulating strings. | strlen(), strcpy(), strcmp(), strcat(), strlwr(), strupr(), strrev() |
time.h | Used for manipulating time and date. |
0 comments:
Post a Comment