• Follow Us

Introduction of C

C is a general-purpose programming language. It was closely related to the UNIX system where it was developed since both the system and most programs running on it are written in C.

Many of C’s important ideas come from the BCPL language developed by Martin Richards.¬†On the contrary, C provides various types of data. The data types of C programming language are characters, integers, and floating-point numbers of several sizes.

C is a relatively low level of language. C does not require any operations to work directly with complex objects, such as character strings, sets, lists, or arrays.

Like syntax of Java, PHP, JavaScript, and other languages are mainly based on C language. C++ is nearly a superset of C language (There are few programs that may compile in C, but not in C++).

Example of a C Program

#include<stdio.h>
int main()
{
int a=100;
printf("%d",a);
}

Structure of a C Program

Inclusion of Header Files

The first and foremost component is to include the header files in C.
The header file is a .h file that contains C function declarations and macro definitions that must be shared between multiple source files.

Some of the C header files are:

stdio.h - defines the basic functions of input and output
stdlib.h - defines numerical conversion functions, pseudorandom network generator, memory allocation
string.h - Defines string processing functions
stddef.h - Defines several useful types and macros.
stdint.h - Defines the exact types of exact width.
math.h - defines common math functions

Syntax for including the header file in C is:

#include <(header_file_name) .h>

Declaration of the Main Method

The next step of C is to declare the main () function.
The syntax for declaring the main method is:

int main ()
{
}

Declaration of Variable

After the declaration of the main method, the declaration of the variable is done. In C, no variable can be used without declaration. Also in C, variables must be declared before any function operation.

Syntax for declaring the variable:

int main()
{
    int a;
.
.

Body

This applies to operations performed in functions. It can be anything like manipulation, search, sorting, printing and more.

Example:

int main()
{
    int a;

    printf("%d", a);
}

Return Statement

The return statement in C returns function’s values. 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;
}

 

Leave a Reply

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

Shopping cart