Get free ebooK with 50 must do coding Question for Product Based Companies solved
Fill the details & get ebook over email
Thank You!
We have sent the Ebook on 50 Must Do Coding Questions for Product Based Companies Solved over your email. All the best!

Introduction to c language for beginners

Last Updated on March 21, 2022 by Ria Pathak

C is a general-purpose procedural programming language developed by Dennis M. Ritchie. It was used to develop the UNIX operating system so you can understand how powerful it really is. Most of the time you might not see it being used in modern development projects but let me tell, most of the modern languages, frameworks, libraries etc. are mostly based on C. Let’s dig in this amazing language to make your coding in C fun.

Application of C

C is a system development language which produces codes which is as fast as the assembly language. The various applications of C language are –

  • Operating Systems
  • Databases
  • Utility tools
  • Text Editors
  • Driver programs

    Basic Functionalities of a C program

    Let’s try to understand a basic Hello World program in C.

    #include <stdio.h>
    int main() {
    printf("Hello World!");
    return 0;
    }

    This program prints “Hello World!”. But how it is done internally?

    Components of C program

    This program is few parts –

  • Header Files – stdio.h –it defines core input and output functions. This is included in the c program using #include
    • We have more header files like – stdlib.h, string.h, math,h etc.
  • Main function – this is the starting point of our program execution. This is the body of our program and any function has to be called from this to execute it. We can also declare variables here.
  • printf() function is used to print our given string. We can print variables also. Other functions to print is puts(). We can use scanf() to take inputs from the user too.
  • Return statement – this statement is used to exit from executing the main function.
    This is quite the basis of any program we will be dealing with in C.

    Various Data Types in C

  • Primary Data Types – int(store integer), float(store decimal or floating point numbers), char()characters or letters or symbols), void(empty datatype which has no value)
  • Derived Data Types – array(contiguous storage), structure, union, pointers(points to the address of a variable)
    Example Code –
    Let’s have an example to understand better. Suppose we have two integers and we want to add them.
    Code Implementation –

    #include <stdio.h> //core input output headerfile
    int main() { //first line of program execution
    int a = 10; //var1
    int b = 20; //var2
    int sum; //var3
    sum = a + b; //storing the sum in var 3
    printf("%d",sum); //d is for integer variable
    return 0; //exit 
    }

    Here we take two variables in a and b and then we add them up and store them in another variable called sum. Finally, we print the sum using print statement.

So, in this blog, we have tried to explain basics of C language. If you want to build up your foundation in programaming languages including C,C++,Java and Python, which are curated by our expert mentors at PrepBytes, you can follow this link Prepbytes Courses.

Leave a Reply

Your email address will not be published. Required fields are marked *