C Programming Language Introduction

C is a procedural programming language. It was mainly developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system.

The main features of C language include low-level access to memory, a simple set of keywords, and clean style, these features make C language suitable for system programmings like an operating system or compiler development.

Many later languages have borrowed syntax/features directly or indirectly from C language. Like syntax of Java, PHP, JavaScript, and many other languages are mainly based on C language. C++ is nearly a super-set of C programming language (There are few programs that may compile in C, but not in C++).

Let’s discuss about basic structure of c program

Every programming language has its own structure and a way to write program. If we don’t follow the structure or best practice to write program, it will lead compilation error which executing the program. So we should write the program in specified way.

So we are here to discuss to basic structure of a c program. Please read the below picture to understand how does execute.

Basic structure of c program
-logo

The components of the above structure are as follows:-

  • Include header files: The very first line for any c program is to inclusion of header files. The header files has predefined function or property which will be used in c program where we included header file. Header files always being saved as .h extension which contains function declaration and other properties to shared between several source files.

    We use #include keyword to include a header files. For example. #include <stdio.h>

  • Main() Method (entry point): Each program has an entry point from where compiler start execution. In c language, we have main() which is responsible to start execution.

    Let’s see the syntax of write main() function for any c program:-

    Int main() {
    /* main content goes here.. */
    }
  • Variable Declaration: This is the part of a program where we declare variables to use in our program. Keep in mind that every variable needs declaration before using it, otherwise you will see compilation error says Variable not defined.

    Int main() {
    Int a;
    }
  • Body: This is the part of program where we write actual program. Here all kind of operation can be performed like manipulation, searching, sorting or any other calculations.

    Int main() {
    Int a;

    printf(‘cprogrammingsimply.in’);
    }
  • Return Statement:- This statement refer to return any value to that function. Every function have return types based of our uses. If we don’t want to return any values, we generally use void main() which not returns any value. and we want to return a number, we have to use int main() which says returning an integer value.

As above we discussed all the components of c program. Let’s write an example to understand more clearly.

#include <stdio.h>
int main()
{
    int a1 = 10; // declare and define value of variable

    printf("%d", a1); // print value of a1 variable

    return 0; // return zero value to this main() function
}

Please execute this program on your system and let us know by commenting if you found anything incorrect regarding this. Happy learning!!