Friday, September 7, 2012

Introduction to C

Computer does not understand human language .It only deals with machine language so if we want computer to do a task we need a medium  that convert human language to machine language. C is a language through which we give instruction to machine & got required output from machine.
The C programming language was originally developed by Dennis Ritchie of Bell Laboratories, and was designed to run on a PDP-11 with a UNIX operating system. Although it was originally intended to run under UNIX, there was a great interest in running it on other systems. It is an excellent language for this environment because of the simplicity of expression, the compactness of the code, and the wide range of applicability. in simple words,C is a general-purpose programming language.
C is a high-level language that has the advantages of readability, maintainability, and portability.
C is a very efficient language that allows you to get control of computer hardware and peripherals.
C is a small language that you can learn easily in a relatively short time.
Programs written in C can be reused.
Programs written in C must be compiled and translated into machine-readable code before the computer can execute them.
Structure of a c program
 main(  ) 
{ statement 1;
  statement 2 ;
}
function()
{
  variable declarations;
  statement 1;
  statement 2; 
} 


let us write a simple c program
#include  <stdio.h>

main() {
printf("I am dipesh\n");
return 0;
}


#include <stdio.h> -This line tells the compiler to include this header file for compilation.Header file contains prototypes and other compiler/pre-processor directive.Prototypes are also called the basic abstract function definitions. Some common header files are stdio.h,stdlib.h, unistd.h and math.h.
main()- This is a function, in particular it is the main block.
{ } - These curly braces are equivalent to the stating that "block begin" and "block end".These can be used at many places,such as switch and if statement.
printf() - This is the actual print statement which is used in our c program frequently.
 Then the return 0 statement. Seems like we are trying to give something back, and it gives the result as an integer.

No comments:

Post a Comment