C language



C Programming Language

The C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.
The C is the most widely used computer language, it keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers. 

Program : -

A program is a set of instructions for performing a particular task. These instructions are just like English words. The computer interprets the instructions as a 1's and 0's. A program can be written in assembly language as well as high level language. This written program is called as source program. This source program is to be converted to the machine language, which is called as Object Program. Either an Interpreter  or a Compiler will do this.
:- The C has now become a widely used professional language for various reasons.
  • Easy to learn
  • Structured language
  • It produces efficient programs.
  • It can handle low-level activities.
  • It can be compiled on a variety of computer platforms.

About C

  • C was invented to write an operating system called UNIX.
  • C is a successor of B language which was introduced around 1970
  • The language was formalised in 1988 by the American National Standard Institute (ANSI).
  • The UNIX OS was totally written in C by 1973.
  • Today C is the most widely used and popular System Programming Language.
  • Most of the state-of-the-art software's have been implemented using C.
  • Today's most popular Linux OS and RBDMS MySQL have been written in C.

C Programming

A C program can vary from 3 lines to millions of lines and it should be written into one or more text files with extension ".c"


The Interpreter 

A Computer program that reads only one line of a source program (code) at a time and converts it to Object Codes. In case of any errors, the same will be indicated instantly. The program written with interpreter can easily be read an understood by other users. So any one can modify the source code.
                                                                                    Because it is interpreted line by line, it is a much slower may of running a program that one that has been compiled, but easier for learners.

The C Compiler

The source code written in source file is the human readable source for your program. It needs to be "compiled", to turn into machine language so that your CPU can actually execute the program as per instructions given.
An Compiler reads the entire program and converts it to the Object Code. It provide errors not of one line but errors of the entire program. Only error free program can executed. It consumes little time for converting a source program to an Object Program.
This C programming language compiler will be used to compile your source code into final executable program.

Installation on Windows

Now a days there is an .exe file to install C or C++ on your windows. To install C on your machine you need to download setup file. Click here to download now.

Let's see Program Structure of C

========================================================================================
Include header file section
Global Declaration section
/* Comments */
main() 

{  /* comments */
Declaration part 
Executable part   }
User- defined functions
{
}
=========================================================================================
A C program basically consists of the following parts:
  • Preprocessor Commands
  • Functions
  • Variables
  • Statements & Expressions
  • Comments
Consider our first C program :

#include<stdio.h>int main()
{ 
/* my first program in C */  
printf("Hello, World! \n");  
return 0;
}

Let's look parts of the above program:
  1. The first line of the program #include<stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation.
  2. The next line int main() is the main function where program execution begins.
  3. The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program.
  4. The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen.
  5. The next line return 0; terminates main() function and returns the value 0.

Compile & Execute C Program:

Lets look at how to save the source code in a file, and how to compile and run it. Following are the simple steps:
  1. Save the file as hello.c                     (to save : file save and edit noname to your choice  or press F2)
  2. Compile >Compile or press Alt+F9 to compile your code.
  3. If there are no errors in your code the command prompt will take you to the next line and would generate a.out executable file.
  4. Now, to execute your program, Run > Run or press Ctrl+F9
  5. To see your output press Alt+F5
  6. You will be able to see "Hello World" printed on the screen.
Choose topics here : -






No comments:

Post a Comment