Understand C++ Program Parts
First C++ Program that
display output "Welcome to first C++ Program!”. With example below
//C++
Program First Program structure comment
|
1
|
#include
<iostream>
|
2
|
int main()
|
3
|
{
|
4
|
std::cout << "Welcome
to c++ Program !";
|
5
|
}
|
6
|
1-
C++ Program Comment
For more detail click here.
2-
Header #include<iostream>
For
example we are using iostream that is one of the most basic C++
libraries! It is used for input and output.
cin and cout is
example of function for input and output stream.
If you run program without including iostream then error will done because compiler
ask no cout , cin library founded.
3-
main function
4- {
Start
of the function main
5-
Print output code
6- }
Using
namespace std
If you
have noticed that C++ language, you may have seen cout being used
instead of std::cout. Both name the same object: the first one
uses its unqualified name (cout), while the second
qualifies it directly within
the namespace std(as std::cout).
cout is part of the standard library, and all the elements in the standard C++ library are declared within what is called a namespace: Using namespace std.
cout is part of the standard library, and all the elements in the standard C++ library are declared within what is called a namespace: Using namespace std.
//C++
Program First Program structure comment
|
#include
<iostream>
|
using namespace std;
|
int main()
|
{
|
cout << "Welcome
to first c++ Program !";
|
}
|
above program is without using namespace std and here example with using namespace feature.
No comments:
Post a Comment