First C Program and its Structure

0
17
views
First C Program and its Structure
First C Program and its Structure

Hey, Guys welcome to another fresh article, in this article I will come with ‘First C Program and its Structure.’ I hope This Article Helpful for All users, So Guys Let’s Get Started.

First C Program and its Structure – Developed by the startfrombasic.com

The code and explanation :-

Different parts of C program

  • Pre-processor
  • Header file
  • Function
  • Variables
  • Statements & expressions
  • Comments

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, to link the program with the header files required. 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.

Header file

A Header file is a collection of Ready-Made functions, 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. With time, you will have a clear picture of what header files are, as of now consider as a Ready-Made function which comes packaged with the C language and you can use them without worrying about how they work, To use any of the standard functions, the appropriate header file must be included. This is done at the beginning of the C source file. For example, to use the printf() function in a program, which is used to display anything on the screen, the line #include <stdio.h> is required because the header file stdio.h contains the printf() function. All header files will have an extension .h

main() function

main() function is a function that must be there in every C program. Everything inside this function in a C program will be executed. In the above example, int written before the main() function is the return type of main() function. The curly braces { } just after the main() function encloses the body of main() function.

Variable

C variable is a named location in a memory where a program can manipulate the data. This location is used to hold the value of the variable. C variable might be belonging to any of the data type like int, float, char etc. THERE ARE THREE TYPES OF VARIABLES IN C PROGRAM THEY ARE, Local variable , Global variable , Environment variable.

Return statement – return 0;

A return statement is just meant to define the end of any C program. All the C programs can be written and edited in normal text editors like Dev c++ or Notepad++ and must be saved with a file name with extension as .c If you do not add the extension .c then the compiler will not recognize it as a C language program file.

Comments

We can add comments in our program to describe what we are doing in the program. These comments are ignored by the compiler and are not executed. To add a single line comment, start it by adding two forward slashes // followed by the comment. To add multi-line comment, enclose it between /* …. */, just like in the program above.

Hope you find this Article Helpful.

LEAVE A REPLY

Please enter your comment!
Please enter your name here