0% found this document useful (0 votes)
81 views10 pages

Volume of Add Operator: Create 2 Simple Mathematical Operator Function Using C++ Programming Language Software

The document explains how to create two simple mathematical operator functions in C++. It includes the code to calculate the sum and product of two numbers entered by the user. The sum function uses variables A and B, inputs their values, calculates the total as A+B, and displays the result. The product function uses variables A and B, inputs their values, calculates the volume as A*B, and displays the result. It also explains how to compile and run the program in C++.

Uploaded by

Afiq Arefiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views10 pages

Volume of Add Operator: Create 2 Simple Mathematical Operator Function Using C++ Programming Language Software

The document explains how to create two simple mathematical operator functions in C++. It includes the code to calculate the sum and product of two numbers entered by the user. The sum function uses variables A and B, inputs their values, calculates the total as A+B, and displays the result. The product function uses variables A and B, inputs their values, calculates the volume as A*B, and displays the result. It also explains how to compile and run the program in C++.

Uploaded by

Afiq Arefiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

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.

Muhd Afiq

Running the program


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.

Muhd Afiq

3. Write the program

Muhd Afiq

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

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

You might also like