Back to home

Topics

1. History of C

C  is  a  general purpose  Computer  programming  language  developed  in  1972  by  Dennis  Ritchie  at  the  Bell  Telephone  Laboratories  for  use  with  the  Unix  operating  system.  
Although  C  was  designed  for  implementing  system  software,  it  is  also  widely  used  for  developing  portable  application  software.  

C  is  one  of  the  most  popular  programming  languages  of  all  time  and  there  are  very  few  computer  architectures  for  which  sa  C  comiler  does  not  exist.  C  has  greatly  influenced  many  other  popular  programming  languages,  most  notably  C++,  which  began  as  an  extension  to  C.
 
C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.

2.Features of C

  • Rich set of built in functions. They help us in re-using readily available programs.
  • C is a middle level language as it combine the capabilities of low level programming with features of HLL (High Level Language) 
  • Variety of data types: Data like character, numeric and alpha numeric can be handled by C language.
  • C is highly portable: A program written in one computer can be run on another computer. 
  • Structured programming modules: The complex program can be broken into modular form. 
  • Wide acceptability: It is simple and flexible to use. 
3. Compiling and Linking 
 
The process of converting a C source program into an executable program actually takes place in two stages Compiling and Linking.
 
The compiler performs translation from C to machine language. The output of the compiler is called object file. These files are saved with the extension of .obj. In addition to the machine language instructions, the object file has information to aid the linker. The linker combines different object files to produce the actual executable file with the extension exe. 
 
             Block diagram to slow the compilation process. 

4. Writing a single program in C 
 
|* First program*|        |* comment *|
 
# include    |*pre processor directive*|
 
main ()      |* Function name *|
 
{    printf("Hello World"); |* Body of the function main () *| }
 
First line:- |* First Program *| is a comment. Comments in C beings with |*(a slash and a star) and ends with *| (a star and slash). This is not an executable statement. 
 
Second line:- Pre processor directive # include is a header file. C does not have basic commands for input/output of the data. So we use a header file called stdio.h. 
 
Third line:- Main(), marks the beginning of the program that is executed when the program is run. It is a function called by operating system and must be present in every program, on success it returns value 0 to operating system. 

5. Turbo C++ IDE 
 
Turbo C++ IDE is an integrated development environment meant for typing and editing C and C++ programs. 

6.Turbo C++ Menus 
 
The menu bar at the top of the screen is the gateway to the menus. T go to the menu bar, press F10 or click anywhere in on the menu bar. 
 
1. File menu 
 
File menu is used to create new file, open an existing file, save a file, change directories, move to DOS shell and exit C++ editor. The file menu has the following options.
 
a) New
   
'New' opens a new edit window with the default name NONAMExx. CPP (the xx stands for a number between OO to 31) and automatically makes the new edit window active. 

b) Open 
       
The 'open' command displays the open a file dialog box, where you select a program file to open in a one Edit Window. 

c) Save 
       
The 'save' command saves the file that is present in the active Edit Window to the disk. If the file has a default name (such as NONAME00.CPP), turbo C++ opens the 'Save Editor File' dialog box so you can rename the file and save it in a different directory or on a different drive.  

d) Save As 
       
File 'Save As' opens up the 'save file as' dialog box, where you can save the file in the active Edit Window under a different name in a different directory, or on a different drive. 

e) Print 
       
The 'print' command prints the contents of the active window contents, output or message window. 

f) DOS shell 
         
With the 'Dos shell' command, you can leave Turbo C++ temporary to perform a DOS command or enter another program. 
To return to Turbo C++, type EXIT at the DOS prompt, then press enter. 

g) Quit 
       
The Quit command exits Turbo C++, removes the environment from memory, and returns to DOS.

2) Edit Menu 
         
The 'Edit' menu provides commands to cut, copy and paste text in Edit windows. You can open a clipboard window to view or edit its contents, and copy text from Messages, Output and Help windows. 

a) Undo
       
The 'Undo' command reverses last editing command you performed in a line. 

b) Redo 
       
The 'Redo' command reverses the effect of the most recent Undo command. Redo has an effect only immediately after an Undo command or another Redo command. 

c) Cut 
       
The cut command removes the selected text from your document and place the text in the clipboard. The text remains selected on the clipboard so you can paste it as many times as you want and wherever you want. 

d) Copy 
         
The 'copy' command leaves the selected text intact and places an exact copy of it on the clipboard. You can then paste that text into any other document with the paste command. 

e) Paste
       
The 'Paste' command inserts the text from the clipboard into the current window at the cursor position. The text that is actually pasted is the currently marked block in the clipboard window. 

f) Clear
         
The 'clear' command removes the selected text but, does not put it on the clipboard. This means you cannot paste the text as you could if you had chosen cut or copy. The cleared text is not retrievable. 

3) Compile Menu 
             
The commands on the 'Compile Menus' are used to compile the program in the active Edit Window, or to build your project. 

a) Compile 
         
The 'compile' command compiles the active editor file (a .C or .CPP file) to an .OBJ file. When Turbo C++ is compiling a status box pops up to display the compilation results: lines compiled, number of errors and warnings, and available memory. 

4) Run Menu 
           
The 'Run Menu' provides command to run your program and to start and end debugging sessions. 

Run:- The run command runs your program, using any arguments you pass to it using the arguments command. 

7) Pre processor 
  • The 'Pre processor' is a translation phase that is applied  to your source code before the compiler processes it. 
  • Generally, the preprocessor perform textual substitutions on your source code. 
  Example:- # include that occurs in the sample program in a preprocessor directive. 
  • The preprocessor processes the C program before the compiler. The # include directive causes the preprocessor to effectively insert the stdio.h file into C program. 
  • A header file is a file containing C declarations and macro definitions to be shared between several source files. You request the use of a header file in your program by including it, the C preprocessing directive #include. 
8) Rules for writing C programs 
  1. C programs should be written in lower case. 
  2. All the statements ends with a semicolon. 
  3. Main() is the first function. 
  4. Declare all the variables before using them. 
  5. Every opening brace or parenthesis should have a closing brace or parenthesis. 
9. Case sensitiveness 

C language case sensitive, ie, upper case and lower case letters are recognized different 
 
Example:- Printf ("hello"); |* correct *|
                PRINTF ("hello"); |*error*|
 
Only the first one can refer to the printf function defined in stdio.h The second statement is an error as PRINTF function is not defined in stdio.h file. 

10.The C compilation process

Steps to execute a C program
  1. Enter the program and save it with .c extension. 
  2. Press Alt+F9 to compile the program on success, it produces an 'object' file. 
  3. Press Ctrl+F9 to run the program on success, it produces an executable file. 
  4. Press Alt + F5 to view the output of the program. 
11.Types of errors

1. Logical:- Logical errors occur when the line of instruction is erroneous. 
 
2. Syntax :- Syntax error occur when the grammar of the C language is not used property. 

For example:- Forgetting case sensitively of C programming language. 
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Powered By