presentation c++

12
Question Create 2 simple mathematical operator function using C++ programming language software. Volume of add operator Volume of multiplication calculator operator Muhd Afiq

Upload: afiq-arefiq

Post on 18-Jul-2016

25 views

Category:

Documents


2 download

DESCRIPTION

c++

TRANSCRIPT

Page 1: Presentation C++

Question

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

Volume of add operator

Volume of multiplication calculator operator

Muhd Afiq

Page 2: Presentation C++

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

Page 3: Presentation C++

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

Page 4: Presentation C++

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

Page 5: Presentation C++

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

Page 6: Presentation C++

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

Page 7: Presentation C++

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

Muhd Afiq

Page 8: Presentation C++

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

Muhd Afiq

Page 9: Presentation C++

6. Wait until compilation process is finished.

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

Muhd Afiq

Page 10: Presentation C++

8. Insert the value for Add

9. You will then get your result.

Muhd Afiq