Breaking News

Introduction to C Programming

                                               A Simple C Program:




1 : Printing a Line of Text


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
/*
A First program in C

*/
#include <stdio.h>
int main()
{
printf("Welcome in C!\n);
return 0;
}

OUTPUT:

Welcome to C! 

  1. Comments
             -- Text surrounded by /* and */ is ignored by computer

             --  Used to describe program
 

      2#include

            --  Preprocessor directive

                    Tells computer to load contents of a certain file


            --   allows standard input/output operations

 
       3.  int main()

              --  C++ programs contain one or more functions, exactly one of which 
                   must be  main
 
            - -   int means that main "returns" an integer value


            - -   Braces ({ and }) indicate a block

            - -   The bodies of all functions must be contained in braces
        4.  printf( "Welcome to C!\n" );
                 --  Instructs computer to perform an action

                       Specifically, prints the string of characters within quotes (“ ”)

 
               - -   Entire line called a statement
                           All statements must end with a semicolon (;)


              - -   Escape character (\)
                           Indicates that printf should do something out of the ordinary
                           \n is the newline character


         5.  return 0;
               --   A way to exit a function
               --   
return 0, in this case, means that the program terminated normally
               --   
Right brace }
               --  Indicates end of main has been reached
         6.   Linker
               -- When a function is called, linker locates it in the library
               -- Inserts it into object program
               -- If function name is misspelled, the linker will produce an error because it  

                   will  not be able to find function in the library













No comments