Structure of C Program
The
basic Structure of C Program is
as follow:
Document
Section
Links
Section (File)
Definition
Section
Global
variable declaration Section
voidmain
()
{
Variable declaration section
Function declaration section
executable statements;
}
Variable declaration section
Function declaration section
executable statements;
}
voidmain ():
Used to start of actual C program. It includes two parts as declaration part
and executable part.
Variable declaration section:
Used to declare private variable.
Function declaration section: Used
to declare functions of program from which we get required output.
Then,
executable statements are placed for execution.
Function
definition section: Used to define functions which are to be called from main().
C Basic Program
#include<stdio.h>
#include<conio.h>
void main()
{
printf("Welcome to SOLMEYVN…");
}
Difference between Compiler and Interpreter
The
main difference between Compiler and Interpreter is:
Compiler
translates the program statements(Source Code) into Machine Code in one go i.e.
all lines of program simultaneously. That's why all compiler based languages
shows all the errors together.
While
interpreter translates the source code into machine code one statement at a
time. That's why program execution cannot proceed to next statement until the
previous error is corrected/rectified.
Different parts of C program
1. Pre-processor
2. Function
3. Variables
4. expression
5. Comment
Pre-processor: #include < file name>
The first word of any C program. It
is also known as pre-processor. The main work of pre-processor is to initialize
the environment of program, i.e to link the program with the header file.
Example : #include<stdio.h>
#include- Inclusion Directive
< > è
Search file only local file
system
Std- standard
Ièinput
Oèoutput
Main function: main() function is a function that must be used in every C
program. A function is a sequence of statement required to perform a specific
task. main() function starts the execution of C program. In the above example,
int in front of main() function is the return type of main() function. we will
discuss about it in detail later. The curly braces { } just after the main()
function encloses the body of main() function.
Input output function:
scanf() and printf() functions
No comments:
Post a Comment