Introduction to C Programming

0


     




                       What is C programming?

C is a general-purpose programming language that is extremely popular, simple and flexible. It is a machine-independent, a structured programming language that is used extensively in various applications.
C was the basic language to write everything from operating systems (Windows and many others) to complex programs like the Oracle database, Git, Python interpreter and more.
It is said that 'C' is a god's programming language. One can say, C is a base for the programming. If you know 'C,' you can easily grasp the knowledge of the other programming languages that use the concept of 'C'
It is essential to have a background in computer memory mechanisms because it is an important aspect when dealing with the C programming language.














best 10 top programming languages in 2018


C Language Introduction & History


The base or father of programming languages is 'ALGOL.' It was first introduced in 1960. 'ALGOL' was used on a large basis in European countries. 'ALGOL' introduced the concept of structured programming to the developer community. In 1967, a new computer programming language was announced called 'BCPL' which stands for Basic Combined Programming Language. BCPL was designed and developed by Martin Richards, especially for writing system software. This was the era of programming languages. Just after three years, in 1970 a new programming language called 'B' was introduced by Ken Thompson that contained multiple features of 'BCPL.' This programming language was created using the UNIX operating system at AT&T and Bell Laboratories. Both the 'BCPL' and 'B' were system programming languages.
   Typing discipline: Static, weak, manifest, nominal
        Designed by: Dennis Ritchie
     Filename extensions: c,.h
    Developer: Dennis Ritchie & Bell Labs (creators); ANSI X3J11         (ANSI C); ISO/IEC JTC1/SC22/WG14 (ISO C)


In 1972, a great computer scientist Dennis Ritchie created a new programming language called 'C' at the Bell Laboratories. It was created from 'ALGOL', 'BCPL', and 'B' programming languages. 'C' programming language contains all the features of these languages and many more additional concepts that make it unique from other languages.
'C' is a powerful programming language that is strongly associated with the UNIX operating system. Even most of the UNIX operating system is coded in 'C'. Initially 'C' programming was limited to the UNIX operating system, but as it started spreading around the world, it became commercial, and many compilers were released for cross-platform systems. Today 'C' runs under a variety of operating systems and hardware platforms. As it started evolving many different versions of the language were released. At times it became difficult for the developers to keep up with the latest version as the systems were running under the older versions. To assure that 'C' language will remain standard, American National Standards Institute (ANSI) defined a commercial standard for 'C' language in 1989. Later, it was approved by the International Standards Organization (ISO) in 1990. 'C' programming language is also called 'ANSI C'.


History of C

Languages such as C++/Java are developed from 'C'. These languages are widely used in various technologies. Thus, 'C' forms a base for many other languages that are currently in use.

Where is C used? Key Applications

  1. 'C' language is widely used in embedded systems.
  2. It is used for developing system applications.
  3. It is widely used for developing desktop applications.
  4. Most of the applications by Adobe are developed using 'C' programming language.
  5. It is used for developing browsers and their extensions. Google's Chromium is built using 'C' programming language.
  6. It is used to develop databases. MySQL is the most popular database software which is built using 'C'.
  7. It is used in developing an operating system. Operating systems such as Apple's OS X, Microsoft's Windows, and Symbian are developed using 'C' language. It is used for developing desktop as well as mobile phone operating systems.
  8. It is used for compiler production.
  9. It is widely used in IOT applications.

Why should we learn 'C'?

As we studied earlier, 'C' is a base language for many programming languages. So, learning 'C' as the main language will play an important role while studying other programming languages. It shares the same concepts such as data types, operators, control statements, and many more. 'C' can be used widely in various applications. It is a simple language and provides faster execution. There are many jobs available for a 'C' developer in the current market.
Beginning with C programming:
  1. Structure of a C program
    After the above discussion, we can formally assess the structure of a C program. By structure, it is meant that any program can be written in this structure only. Writing a C program in any other structure will hence lead to a Compilation Error.  
  2. The structure of a C program is as follows:
       
    The components of the above structure are:
    1. Header Files Inclusion: The first and foremost component is the inclusion of the Header files in a C program.
      A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.
      Some of C Header files:
      • stddef.h – Defines several useful types and macros.
      • stdint.h – Defines exact width integer types.
      • stdio.h – Defines core input and output functions
      • stdlib.h – Defines numeric conversion functions, pseudo-random network generator, and memory allocation
      • string.h – Defines string handling functions
      • math.h – Defines common mathematical functions
      Syntax to include a header file in C:

      #include

    2. Main Method Declaration: The next part of a C program is to declare the main() function. The syntax to declare the main function is:
      Syntax to Declare main method:

      int main()
      {}

    3. Variable Declaration: The next part of any C program is the variable declaration. It refers to the variables that are to be used in the function. Please note that in C program, no variable can be used without being declared. Also in a C program, the variables are to be declared before any operation in the function.
      Example:

      int main()
      {
      int a;.
      .

    4. Body: The body of a function in C program, refers to the operations that are performed in the functions. It can be anything like manipulations, searching, sorting, printing, etc.
      Example:

      int main()
      {
      int a;
      printf("%d", a);.
      .

    5. Return Statement: The last part of any C program is the return statement. The return statement refers to the returning of the values from a function. This return statement and return value depend upon the return type of the function. For example, if the return type is void, then there will be no return statement. In any other case, there will be a return statement and the return value will be of the type of the specified return type.
      Example:

      int main()
      {
      int a;
      printf("%d", a);
      return 0;}
        1. Writing first program:

      1. Following is first program in C

        #include <stdio.h>


        int main(void)



        {


         printf("HindiCodingCommunity");     


        return 0;


        }


        Let us analyze the program line by line.
        Line 1: [ #include <stdio.h> ] In a C program, all lines that start with are processed by preprocessor which is a program invoked by the compiler. In a very basic term, the preprocessor takes a C program and produces another C program. The produced program has no lines starting with #, all such lines are processed by the preprocessor. In the above example, preprocessor copies the preprocessed code of stdio.h to our file. The .h files are called header files in C. These header files generally contain a declaration of functions. We need stdio.h for the function printf() used in the program.
        Line 2 [ int main(void) ] There must to be the starting point from where execution of compiled C program begins. In C, the execution typically begins with the first line of main(). The void written in brackets indicates that the main doesn’t take any parameter . main() can be written to take parameters also. We will be covering that in future posts.
        The int wrote before main indicates return type of main(). The value returned by main indicates status of program termination. 
        Line 4 [ printf(“HindiCodingCommunity”); ] printf() is a standard library function to print something on standard output. The semicolon at the end of printf indicates line termination. In C, semicolon is always used to indicate the end of the statement.
        Line 5 [ return 0; ] The return statement returns the value from main(). The returned value may be used by the operating system to know the termination status of your program. The value 0 typically means successful termination.
      2. Line 3 and 6: [ { and } ] In C language, a pair of curly brackets define the scope and mainly used in functions and control statements like if, else, and loops. All functions must start and end with curly brackets. 
      3. How to execute the above program:
        In order to execute the above program, we need to have a compiler to compile and run our programs. 
        Windows: There are many compilers available freely for the compilation of C programs like Code Blocks and Dev-CPP.   We strongly recommend Code Blocks.

              This video is only for beginners
        

                                       Lecture 1 Introduction to C Part 1 hindi


      for download, pptx click here


      If you want to write articles for us please contact us at hindicodingcommunity@gmail.com

      Post a Comment

      0Comments
      Post a Comment (0)

      #buttons=(Accept !) #days=(20)

      Our website uses cookies to enhance your experience. Learn More
      Accept !