STYLE SWITCHER

BODY SKIN


Purchase
×

My blog

C Language :

C Language :

C is a structured programming language developed by Dennis Ritchie in 1973 at Bell Laboratories. It is one of the most popular computer languages because of its structure, high-level abstraction, machine independent feature etc.

C language was developed to write the UNIX operating system.

History of C language:

C language has evolved from three different structured language ALGOL, BCPL and B Language. It uses many concepts from these languages while introduced many new concepts such as datatypes, struct, pointer etc. In 1988, the language was formalised by American National Standard Institute(ANSI). In 1990, a version of C language was approved by the International Standard Organisation(ISO) and that version of C is also referred to as C89.


C Program and its Structure:

#include <stdio.h>

int main()

{

Int a;

printf("Hello,World");  //single line comment

return 0;

/*

   multi

   line

   comments

/*

}


Out Put : Hello,World

#include (Pre-processor) :

#include is the first word of any C program. It is also known as a pre-processor. The task of a pre-processor is to initialize the environment of the program, Pre-processor is to link the program with the header files required.


<stdio.h> (Header file) :

A Header file is a collection of built-in(readymade) functions (A function is a unit of code that is often defined by its role within a greater code structure.), which we can directly use in our program. Header files contain definitions of the functions which can be incorporated into any C program by using pre-processor #include statement with the header file. Standard header files are provided with each compiler, and covers a range of areas like string handling, mathematical functions, data conversion, printing and reading of variables.

So, when we say #include <stdio.h>, it is to inform the compiler to include the stdio.h header file to the program before executing it.


why we use header files :

Header files are used in C to reduce the work that programmer  generally do that by typing each and every function or method we use in programming and they are seperately placed in a seperate file saved with .h extensions these are generally grouped togrther  into a single file called header file based upon the functionalities they carry out such as INPUT, OUTPUT features are all present in stdio.h file. so by including this header file we can directly use printf and scanf as a keywords without any code required.

we can also define our header files on our own if we use those methods regularly to include it the syntax must be as.



main() function (Main Method Declaration) :

The next part of a C program is to declare the main() function. The syntax to declare the main function  is the entry point of any C program. It is the point at which execution of program is started.

When a C program is executed, the execution control goes directly to the main() function. Every C program have a main() function.


Void Main():

Void is a keyword in C language, void means nothing, whenever we use void as a function return type (Return Type is a specifies the output type of a function. The output type can be a number,text etc.) then that function nothing return. here main() function no return any value.


Int Main () :

In place of void we can also use int return type of main() function, at that time main() return integer type value.


Variable :

When we want to store any information(data) on our computer/laptop, we store it in the computer's memory space. Instead of remembering the complex address of that memory space where we have stored our data, our operating system provides us with an option to create folders, name them, so that it becomes easier for us to find it and access it.

Similarly, in C language, when we want to use some data value in our program, we can store it in a memory space and name the memory space so that it becomes easier to access it.

The naming of an address is known as variable. Variable is the name of memory location. Unlike constant, variables are changeable, we can change value of a variable during execution of a program. A programmer can choose a meaningful variable name. Example : average, height, age, total etc.


Rules for naming c variable :

Variable name must begin with letter or underscore.

Variables are case sensitive

They can be constructed with digits, letters.

No special symbols are allowed other than underscore.


Data Type :


in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. A string, for example, is a data type that is used to classify text and an integer is a data type used to classify whole numbers.

The data type defines which operations can safely be performed to create, transform and use the variable in another computation.


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.

Body :

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.


Return statement - return 0 :

A return statement is just meant to define the end of any C program.




31-Mar-2019