Structure of C++ Program
Structure of c program
will explain the step of c program in how many step a program will developed so
there are the step:-
1.
Comment Line
2.
Header file declaration
3.
Main function
4.
Opening barse
5.
Body of program
6.
Closing barse
·
/* Comments */
Comments
are a way of explaining what makes a program. The compiler ignores comments and
used by others to understand the code.
·
#include<stdio.h>
#include is a
specific preprocessor command that effectively copies and pastes the entire text of the file, specified between
the angle brackets, into the source code.
The
file iostream which is a standard file that
should come with the C++ compiler, is
short for input-output streams.
This command contains code for displaying and getting an input from the user.
iostream file defines two names used in this program - cout and endl.
·
int/void main()
int/void
is a return value, which will be explained in a while.
·
main()
The
main() is the main function where program execution begins. Every C program
must contain only one main function. Or This is the main function, which is the
default entry point for every C program and the void in front of it indicates
that it does not return a value.
·
Braces
Two
curly brackets "{...}" are used to group all statements. Or Curly
braces which shows how much the main() function has its scope.
·
Cout<<
The name cout is short for character output and displays
whatever is between the << brackets.
Symbols such as << can also behave like functions and are used with the
keyword cout.
Example:
/*
write a program to print hello */
#include<iostream.h>
#include<conio.h>
void
main()
{
Cout<<“hello
sir welcome to today class of c”;
getch();
}
Output:
Hello
sir welcome to today class of c
No comments:
Post a Comment