Learn C++ with M Numan Sharif
We
will not come here for learning the history
c++. We are here for learning the c++ code.
So
let start from the writing the first program in C++.
Environment:
You must have to be installed
“Dev C++” in your computer for writing the C++ code.
There are three major parts of a
c++ program.
I.
Preprocessor directive.
II.
Main Function.
III.
Body of the program
Below program will explain these
above things.
·
·
Open Dev C++
Hit “CTRL+N”(for new file)
·
Start writing the code
//
Write a program that print
“Hello
your name” //
#include<iostream>
#include<conio.h>
using
namespace std;
int
main()
{
cout<<"Hello
M Numan Sharif ";
getch();
return
0;
}
Now
see the program we will discuss the program in detail
#include<iostream> Header files
#include<conio.h>
using
namespace std;
int
main() main function
{
cout<<"Hello
M Numan Sharif "; Body of the program
getch();
return
0;
}
1. Header File/ Processor directive:-
#include is known as processor as it includes all
the header files which contain different predefined functions.
Let see the some function of heade file “iostream”
cout
|
For
display the values.
|
Cin
|
For
input values from the user.
|
2.
Main Function :-
Remember one thing that a compiler start compiling a
program from main function and execute every line sequentially.
Here one thing to be noticed that if a program have
not a main function then what is the result will produced?
Answer is simple, that program will be complied but
never be execute or run because that program have not a main function
3. Body of the main function:-
Anything or any task written in the main function is
called body of the program.
Every line in the body must be ended with semicolon (
; ).
0 comments:
Post a Comment
Thank you for joining us we will response very soon