Tuesday, 1 August 2017

Basic details of C language in one Click

Origin of C
In 1970 a programmer, Dennis Ritchie, created a new language called C.
  • The name came about because it superseded the old programming language he was using : B.
  • C was designed with one goal in mind: writing operating systems.
  • The language was extremely simple and flexible, and soon was used for many different types of programs.
  • It quickly became one of the most popular programming languages in the world.



Features of C

  • Fast and Efficient
    Programs written in C are efficient and fast. This is due to its variety of data type and powerful operators.
  • Portable
    C is highly portable. This means that programs once written can be run on another machines with little or no modification.
  • Function and Rich Libraries
    C program is basically a collection of functions that are supported by C library. We can also create our own functions and add it to the C library.
  • Modularity
    Modular programming is a software design technique that increases the extent to which software is composed of separate parts, called modules.
  • Easy to Extend
    In C, New feature can be added at any time by programmer.
  • Case Sensitive
    It is a case sensitive language, that it can differentiate the character is upper case or lower case.

IDE AND COMPILER

List of some good IDE + Compiler for C.

Code::Blocks with Mingw (We Recommend this)

It's Free

Dev C++ with Mingw/GCC

It's Free

Xcode

It's Free
What is Compiler:
A compiler is a computer program that transforms human readable source code of another computer program into the machine readable code that a CPU can execute.
What is Interpreter:
An interpreter is a computer program that directly executes, i.e. performs, instructions written in a programming or scripting language, without previously compiling them into a machine language program.
  • Interpreter Takes Single instruction as input.
  • No Intermediate Object Code is Generated.
  • Interpreter execute conditional control statements at a much slower speed.
  • Memory Requirement is Less.
  • Every time higher level program is converted into lower level program.
  • Errors are displayed for every instruction interpreted (if any).
  • The interpreter can immediately execute high-level programs, thus interpreters are sometimes used during the development of a program, when a programmer wants to add small sections at a time and test them quickly.


Structure of C program


  • C is a case sensitive language.
  • C Program consist of one or more functions.
  • One function that must be present in every C program is main(). This is the 1st function called up when program execution begins.

C program basically consists of the following parts:

  • Preprocessor Commands
  • Functions
  • Variables
  • Statements & Expressions
  • Comments
Structure of C Program is illustrated below :

//Preprocessor directives

//Global data declarations

main() // main function
{
    //Declaration part;

    //Program statements;

}

//User defined functions
func1()
{
    ....
}

func2()
{
    ....
}

.
.
.

funcn()
{
    ....
}
    



Simple C program

Let's write c program to print Hello World.
PROGRAM CODE

/*Program to print a Hello World*/

//header file
#include<stdio.h>

//main function
int main()
{
    //Output statement
    printf("Hello World");

    //returning value to function
    return 0;
}

    


No comments:

Post a Comment