• Breaking News

    Wednesday, December 26, 2018

    How to create your first 'C' program

                          YOUR FIRST 'C' PROGRAM 


    Lot's of theory! Now let's put all the theory into action by writing few programs which will clarify your concepts studied so far.
        So let gets on with our first program which simply prints Hello world on to the screen

    /* Program 1.0 printing Hello world on the screen */
    #include <stdio.h>
    main( )
    {
    printf ("Hello world");

    }

    Output :
    Hello world

    EXPLANATION :- Whatever written inside /*and*/ is treated as comment, and is  ignored by the C compiler. You may also comment multiple lines as we will see in the coming programs. We use comments to write which program we are going to make or to write some remarks about instruction for better understanding.
     #include is the processor directive. stdio.h is the standard input output header file (due to .h extension ) which is to be  included in every C program. There may be space between #include and <stdio.h> . Next line is the function main ( ) due  to symbol ( ) which is known as function symbol.
    This function must be present in every C file you make because execution of your  C program starts from this main ( ). { is the opening brace for main function and } is the closing brace. All statements, instructions are written inside the main function. Printf () is the inbuilt function (pre built in C compiler ) which parts whatever written inside " " on to the screen , so the output. C is case-sensitive programming language , so what ever you use that is in-built C has to be in lower case.
         The declaration of printf function is given in the header file stdio.h Every statement in C program has to ind with ; (semicolon).

    PROGRAMMING EXAMPLE PART-2

    /* Program 1.1 A C PROGRAM WITH TWO PRINTF */
    #include <stdio.h>
    main( )
    {
    printf ("Hello world");
    printf ("C program");

    }

    Output :
    Hello world C program

    EXPLANATION :- We have used two printf statements in the program. By default the output is produced on the same line. If we want output to be placed on the next line we can do so as this done in the next program.

    /* Program 1.1 A C PROGRAM WITH TWO PRINTF */
    #include <stdio.h>
    main( )
    {
    printf ("Hello world \n");
    printf ("C program");

    }


    Output :
    Hello world 
    C program

    EXPLANATION :-  After printing Hello world  on the first line, line is changed by the inclusion of new line character \n. It can also placed in the beginning of second printf statement as printf ("\n Sencond Program") . Note the "\" is known as backlash and "/" known as forward slash. The usual mistake committed by beginners is to write "/" instated of  "\"

    CLICK NOW FOR MORE READ ....
    MACHINE LANGUAGE

    C- Programming 


    What is a computer Virus ?






    No comments:

    Post a Comment

    Update

    list of ministers of india 2019

                                list of ministers of india 2019 | 1. Narendra Modi - Prime Minister,  Public Grievances and Pensions, ...

    Contact Us

    Email:- soumyadipmandal9@gmail.com