using namespace std;
All the elements of the standard C++ library are declared within what is called a namespace, the
namespace with the name std. So in order to access its functionality we declare with this expression that
we will be using these entities. This line is very frequent in C++ programs that use the standard library,
and in fact it will be included in most of the source codes included in these tutorials.
Sunday, December 11, 2011
Notes of C++
#include
Lines beginning with a hash sign (#) are directives for the preprocessor. They are not regular code lines
with expressions but indications for the compiler's preprocessor. In this case the directive #include
tells the preprocessor to include the iostream standard file. This specific file (iostream)
includes the declarations of the basic standard input-output library in C++, and it is included because its
functionality is going to be used later in the program.
Lines beginning with a hash sign (#) are directives for the preprocessor. They are not regular code lines
with expressions but indications for the compiler's preprocessor. In this case the directive #include
includes the declarations of the basic standard input-output library in C++, and it is included because its
functionality is going to be used later in the program.
How to compile and run a c++ program using command prompt
There are two ways to compile your program
first one is thru command prompt
steps for that are as follows.
1. go to start--all programs--Microsoft Visual Studio 2010-- Visual Studio Tools-- Visual Studio command prompt(2010)
2. Let us say it shows c:\Documents and Settings\xyz\abc>
and your source1.cpp file is saved at address c:\Documents and Settings\xyz\mnp\Source1.cpp
then you first type in cd .. [enter]
it will now show c:\Documents and Settings\xyz> as the last line in command prompt
what cd .. actually did is take you one folder back
you may need to use cd .. in case you have to go a few folders back
3. After that I tyoed cd mnp as below
c:\Documents and Settings\xyz> cd mnp
and as a result the last line in command prompt showed
c:\Documents and Settings\xyz\mnp\
now write cl Source1.cpp in front of c:\Documents and Settings\xyz\mnp\ and a few lines will be written on command prompt at the end of which it would show
/out :Source1.exe
Source1.obj
This means Source1.cpp has been compiled and as an output .exe and .obj files have been generated.
But in case the program has some syntax error it would not show
/out :Source1.exe
Source1.obj
instead of that it will show syntax error
4. After the compilation is over. You run the program by simplying typing in Source1 as below
c:\Documents and Settings\xyz\mnp\Source1
As a result the program will get executed.
Thanks a lot.
first one is thru command prompt
steps for that are as follows.
1. go to start--all programs--Microsoft Visual Studio 2010-- Visual Studio Tools-- Visual Studio command prompt(2010)
2. Let us say it shows c:\Documents and Settings\xyz\abc>
and your source1.cpp file is saved at address c:\Documents and Settings\xyz\mnp\Source1.cpp
then you first type in cd .. [enter]
it will now show c:\Documents and Settings\xyz> as the last line in command prompt
what cd .. actually did is take you one folder back
you may need to use cd .. in case you have to go a few folders back
3. After that I tyoed cd mnp as below
c:\Documents and Settings\xyz> cd mnp
and as a result the last line in command prompt showed
c:\Documents and Settings\xyz\mnp\
now write cl Source1.cpp in front of c:\Documents and Settings\xyz\mnp\ and a few lines will be written on command prompt at the end of which it would show
/out :Source1.exe
Source1.obj
This means Source1.cpp has been compiled and as an output .exe and .obj files have been generated.
But in case the program has some syntax error it would not show
/out :Source1.exe
Source1.obj
instead of that it will show syntax error
4. After the compilation is over. You run the program by simplying typing in Source1 as below
c:\Documents and Settings\xyz\mnp\Source1
As a result the program will get executed.
Thanks a lot.
How to write your first program in C++ using visual c++ 2010
I compiled and ran my first c++ program today using visual c++ 2010 today. If you wanna do as well, here are the steps.
1. google search for download visual c++ 2010
2. download visual c++ 2010
it will take about 20 minutes.
3. after that go to start --> all programs-->Microsoft Visual Studio 2010 -->( with an icon of lying oo in front of this) Microsoft Visual Studio 2010
A window will open up finally.
Select under the File menu--new---> File
Select Visual C++ among the installed templates and c++ File(.cpp) in the menu which will come in the center of the newly opened window after you selct Visual C++ in the list of installed tempaltes at the right.
It will open up a Source1. cpp, you can start writing your program under Source1.cpp tab
// my first program in C++
#include
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Above is a sample program
After you are done with your program.
You need to compile your program and then run it. Steps for compiling and running the program are in my next blog
1. google search for download visual c++ 2010
2. download visual c++ 2010
it will take about 20 minutes.
3. after that go to start --> all programs-->Microsoft Visual Studio 2010 -->( with an icon of lying oo in front of this) Microsoft Visual Studio 2010
A window will open up finally.
Select under the File menu--new---> File
Select Visual C++ among the installed templates and c++ File(.cpp) in the menu which will come in the center of the newly opened window after you selct Visual C++ in the list of installed tempaltes at the right.
It will open up a Source1. cpp, you can start writing your program under Source1.cpp tab
// my first program in C++
#include
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Above is a sample program
After you are done with your program.
You need to compile your program and then run it. Steps for compiling and running the program are in my next blog
Wednesday, December 7, 2011
Essentials of good paragraph construction
Essentials of good paragraph construction are -
1. Unity
2. A good topical sentence
3. Logical sequence of thought
4.Variety
5. A full and rounded final sentence in conclusion
1. Unity
2. A good topical sentence
3. Logical sequence of thought
4.Variety
5. A full and rounded final sentence in conclusion
Tuesday, December 6, 2011
Subscribe to:
Posts (Atom)