Presentation C++

Preview:

DESCRIPTION

c++

Citation preview

Question

Create 2 simple mathematical operator function using C++ programming language software.

Volume of add operator

Volume of multiplication calculator operator

Muhd Afiq

Explanation of the program commands.

Volume of Add Operator.

#include <iostream>

This specific file includes the declarations of the basic standard input – output library in C++ and is included because its functionality will be used later in the program.

#include <stdlib.h>

This specific file includes the declarations of the standard library in C++ and is included to access the standard library in the program.

using namespace std;

All elements of the standard C++ library are declared within a namespace, the namespace with the name std.

int main ()

Muhd Afiq

This is the point where all C++ programs start their execution. The pair of parentheses ( () ) are used to include parameters within them. Followed by int main () are a pair of braces ({}) which encloses the body of the main function.

int ;

The int is used to declare the variable “ A,B,total”.

std::cout<<

This is the standard output stream in C++.

“/n==================Program ini mengittung nilai tambah================”

This line is a C++ statement and is a visible effect in the program. “\n” is used to make a new line after the statement or before if placed in front.

std::cin>>

This is the standard input stream in C++.

Total = A+B;

system (“PAUSE”);

This will pause the program after execution is done, allowing users to see the results.

return 0;

This statement causes the main function to finish.

;

The semicolon character is used to mark the end of a statement.

Muhd Afiq

Volume of multiplication operator.

#include <iostream>

This specific file includes the declarations of the basic standard input – output library in C++ and is included because its functionality will be used later in the program.

#include <stdlib.h>

This specific file includes the declarations of the standard library in C++ and is included to access the standard library in the program.

using namespace std;

All elements of the standard C++ library are declared within a namespace, the namespace with the name std.

Muhd Afiq

int main ()

This is the point where all C++ programs start their execution. The pair of parentheses ( () ) are used to include parameters within them. Followed by int main () are a pair of braces ({}) which encloses the body of the main function.

int A,B,Volume;

The int is used to declare the variables A,”B” and “Volume”.

std::cout<<

This is the standard output stream in C++.

“"\n=================Program ini menghitung nilai darab=============== "”

This line is a C++ statement and is a visible effect in the program. “\n” is used to make a new line after the statement or before if placed in front.

std::cin>>

This is the standard input stream in C++.

Volume = A*B

The symbol “*” will multiply the variables A,B, and will be the variable to output as Volume.

system (“PAUSE”);

This will pause the program after execution is done, allowing users to see the results.

return 0;

This statement causes the main function to finish. The semicolon character is used to mark the end of a statement.

Running the program

Muhd Afiq

1. Go to start>>all programs>>select Dev C++ (or other C++ related programs).

2. Click the tab “file” and then select “New Source File”.

3. Write the program

Muhd Afiq

4. Compile the project by clicking the “Execute” tab and choosing “Compile and run” or just press F11.

Muhd Afiq

5. Save the file with respective names corresponding to the function of the program.

Muhd Afiq

6. Wait until compilation process is finished.

7. The program will then run automatically. A command prompt screen will appear.

Muhd Afiq

8. Insert the value for Add

9. You will then get your result.

Muhd Afiq