C language – Introduction to C programming language

Introduction to C language

The C language is a general-purpose, high-position language that was firstly developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was first enforced on the DEC PDP-11 computer in 1972.

In 1978, Brian Kernighan and Dennis Ritchie made the first intimately available description of C, now known as the K&R standard. UNIX operating system, the C compiler, and basically all UNIX operation programs have been written in C.

C language has now come to an extensively used professional language for colorful 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.

Facts about C language

  • C language was constructed to write an operating system called UNIX.
  • C is a successor of the B language, which was introduced around 1970.
  • The language was standardized in 1988 by the American National Standard Institute. (ANSI).
  • The UNIX OS was completely written in C by 1973. now, C is the most globally used and popular System Programming Language. Utmost of the state-of-the-art software has been enforced using C.
  • Today’s most popular Linux OS and RBDMS MySQL have been written in the C programming language.

Why use the C language?

  • C  Programming Language was initially used for system development work, in particular the programs that make up the operating system.
  • C was taken up as a system development language because it produces code that runs almost as fast as code written in assembly language.
  • Some exemplars of the use of C might be:
  • Operating Systems
  •  Language Compilers
  • Assemblers
  • Text Editors
  •  Print Spoolers
  • Network Drivers
  •  Modern Programs
  •  Databases
  • Language Interpreters
  •  Utilities

Environment Setup for C

This section describes how to set up your system environment before you start doing your programming using the C language.

Before you start doing programming using the C programming language, you need the following two software available on your computer,

(a) Text Editor and

(b) The C Compiler.

Text Editor

This will be used to classify your program. Examples of limited editors include Windows Notepad, OS Edit command, Detail, Epsilon, EMACS, and vim or vi. The name and version of the text editor can vary between separate operating systems.

For example, Notepad will be used on Windows, and vim or vi can be used on windows as skillfully as Linux or UNIX.

The files you create with editors are called source files and contain program source code. The source files for C programs are normally named with the extension “.c”.

Before starting your programming, make sure you have one text editor in place and you see enough experience to write a computer program, save it in a file, compile it, and eventually execute it.

The C language compiler

The source code written in the source file is the natural readable source for your program.

It needs to stand “compiled”, to turn into machine language so that your CPU can execute the program as per instructions.

This C programming language compiler will be used to compile your source code into a concluding executable program. I guess you have beginning knowledge about a programming language compiler.

The most commonly used and free available compiler is the GNU C compiler.

C language program Structure

Let’s look into the Hello World example using C Programming Language.

C Hello world example: Let us look at a simple code that would print the words “Hello World”:

A C program basically consists of the following parts:

c program structure

Let’s look at various parts of the above program:

  1. The first line / *. */ will be forgotten by the compiler and it has been put to add further comments in the program. Such lines are called comments in the program.
  2. The first line of the program #include is a preprocessor command, which tells a C compiler to include stdio.h file before going to compilation.
  3. The next line int main() is the main function where program execution begins.
  4. The next line printf (.) is another function usable in C which causes the message “Hello World!” to be displayed on the Console.

Programming Rules in C programming language

  • All statements in C program should be written in lower case letters. Upper case letters are only used for symbolic constants.
  • Blank spaces may be inserted between the words. It is not used while declaring a variable, keyword, constant, and function.
  • The program statement can be written anywhere between the two braces.
  • The user can also write one or more statements in one line separating them with a semicolon (;).

Compile and Execute C Program

how to save the source code in a file, and how to compile and run it?. The Following are the simple steps:

  1. Open the text editor and add the Hello World code.
  2. Save the file name as hello. c 
  3. Open the command prompt and go to the directory where you saved the file.
  4. Type GCC hello.c and click enter to compile your code.
  5. If there are no errors in your code the command prompt will take you to the next line and would bring a.out executable file.
  6. Now, type a.out to execute your program.
  7. You’ll be capable to see“Hello World” printed on the screen.

$ gcc hello.c
$ ./a.out
Hello world

Make good that gcc compiler is in your path and that you’re running it in the directory containing the source file hello.c.

IDE for C language

An IDE (integrated development environment) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools, and a debugger.

Some Free IDE for C programming Language

IDE's for C language

To Download,

  1. QUINCY 2005
  2. Visual Studio Code
  3. Code::Blocks
  4. Turbo C++