Getting Started with C

  What is C and how does it works?

   C is a low-level and powerful language, learning C requires some degree of understanding how computers really work. In this article, you are going to develop the first program in C. You will learn how the sequence of a C program works.

   The C program is a set of functions and always starts executing in a special function which is known as main function . Here the simple program that prints a greeting message "Hello World" on the screen.

   Example:

    #include <stdio.h>

    main()
    {
        printf("Hello World!\n");
    }

Process to compile and run the C program:
  • Write C program in a text editor (eg. Notepad) and save it as dot(.)c extension (eg. hellow_word.c).
     
  • Compile with a C Compiler (eg. gcc hello_world.c). it just produces the executable file as hello_world.exe.
     
  • Run this executable file (eg. gcc -o hello_world).
Let's know how the above program works. 
  • First line is the the #include directive. C program uses this directive to load external function library - stdio is c library which provides standard input/output. The printf () is a function which is declared in the header file called stdio.h
  • The next is the main function - the first entry point of all C programs. C program logic starts from the beginning of main function to the its ending.
  • And finally is the printf  function which accepts a string parameter. The printf function is used to print out the message to the screen.  

Enjoy programming! 

Further questions please inform us.

0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes