Ads by Google
Flowcharts from C/C++
Understand code in less time code-formatting, cross-reference
www.sgvsarc.com
2.
2
Some Examples (Copy and Paste this into a text/code editor)
A simple program is given by Bjarne Stroustrup (developer of C++) to check your compiler:
#include
#include
using namespace std;
int main ()
{
string s;
cout << "jhun \n" ;
cin >> s;
cout << "Hello, " << s << '\n' ;
return 0; // this return statement isn't necessary
}
// The sum of two numbers.
#include
using namespace std;
int main ()
{
int no1, no2, sum ;
cout << "\nEnter the first number = " ;
cin >> no1 ;
cout << "\nEnter the second number = " ;
cin >> no2 ;
sum = no1 + no2 ;
cout << "\nThe sum of "<< no1 <<" and "<< no2 <<" = "<< sum '\n' ;
return 0 ;
}
3.
3
Save this as sum.cpp, Don't confuse there are many other extensions for C++ files, choose any of them (like *.cc, *.cxx, *.c++, *.cp) .
HINT : It should say Save as Type: {select "All Files"}
4.
4
Compile it.
For users of linux and gcc compiler
Command : g++ sum.cpp
Users of Window can use any C++ compiler
Like MS Visual C++ or any they like to use
5.
5
Run the program
For users of Linux and gcc compiler
Command : ./a.out (a.out is a executable file produce by compiler after compilation of program.)
Ads by Google
C++ Database
High Scalability, High Availability Large Data Sets, High Performance
www.versant.com/objectdatabase
Java Upstream Tracker
backward compatibility testing for Java libraries
linuxtesting.org
edit Tips
* For more details about programming in C++ give a visit cplusplus.com
* cin.ignore() prevents the program from ending prematurely and closing the window immediately (before you have time to see it)! Press any key if you want to end the program. cin.get() functions in a similar manner.
* Add // before all of your comments.
* Learn programming in C++ with ISO standards
* Feel free to experiment!
Tidak ada komentar:
Posting Komentar