Вы находитесь на странице: 1из 10

Question

1.Create 2 simple mathematical operation function using c++ programming language


software

Value of sum operation

Value of Substract operation

2.Explanation of the program commands.

Value of sum operation


#include <iostream>
using std::cout;
using std::cin;

int main()
{
int x,y,z, total;
cout << "\n =================== mencarik nilai tambah
==========================";
cout << "\n masuk kan nilai x=";
cin >> x;
cout << "\n masuk kan nilai y=";
cin >> y;
cout << "\n masuk kan nilai z=";
cin >> z;

total= x+y+z;

std::cout << "\n


=====================================================================";

std::cout << "\n nilai x+y+z ialah =" << total;


std::cout <<"\n
=========================================================================";
std::cout << "\n thanks";

return 0 ;
}

I.
II.

# = A hash sign (#) are directives for the pre-processor.


#include = The directive #include tells the pre-processor to include a
standard file.

III.

iostream.h = Header that defines the standard input/output stream objects


and used for cout.

IV.

Int main() = The main function is the point by where all C++ programs start
their execution, independently of its location within the source code.

V.
VI.
VII.

cout = The standard output, normally the screen.


<< = The bitwise left shift (<<) shifts operator bits to the left.
Hello World\n"; = In fact, this statement performs the only action that
generates a visible effect in our first program. A statement is a simple or
compound expression that can actually produce some effect.

VIII.

\n = (new line) Moves the active position to the initial


position of the next line.

IX.

= the separation between statements is specified with an ending semicolon


(;) at the end of each one, so the separation in different code lines does not
matter at all for this purpose.

X.

return 0; = The return statement causes the main function to finish

value of Substract operation

#include <iostream>
using std::cout;
using std::cin;
int main()
{
int x,y,z;
cout << "\n =================== mencarik nilai bahagi
==========================";
cout << "\n masuk kan nilai x=";
cin >> x;
cout << "\n masuk kan nilai y=";
cin >> y;
z= x/y;
std::cout << "\n
=====================================================================";
std::cout << "\n nilai x/y ialah =" << z;
std::cout << "\n
=====================================================================";
return 0 ;
}

XI.
XII.

# = A hash sign (#) are directives for the pre-processor.


#include = The directive #include tells the pre-processor to include a
standard file.

XIII.

iostream.h = Header that defines the standard input/output stream objects


and used for cout.

XIV.

Int main() = The main function is the point by where all C++ programs start
their execution, independently of its location within the source code.

XV.
XVI.
XVII.

cout = The standard output, normally the screen.


<< = The bitwise left shift (<<) shifts operator bits to the left.
Hello World\n"; = In fact, this statement performs the only action that
generates a visible effect in our first program. A statement is a simple or
compound expression that can actually produce some effect.

XVIII.

\n = (new line) Moves the active position to the initial


position of the next line.

XIX.

= the separation between statements is specified with an ending semicolon


(;) at the end of each one, so the separation in different code lines does not
matter at all for this purpose.

XX.

return 0; = The return statement causes the main function to finish

3.Give you answer step by step how to run that program


1.Open programing c++ `search Dev C++

2.Select new source file

3.Write this program


#include <iostream>
Using std::cout;
Using std::cin;
int main()
{
int x,y,z;
cout << "\n =================== mencarik nilai bahagi =======================";
cout << "\n masuk kan nilai x=";
cin >> x;
cout << "\n masuk kan nilai y=";
cin >> y;

z= x/y;

std::cout << "\n =====================================================================";

std::cout << "\n nilai x/y ialah =" << z;

std::cout << "\n =====================================================================";

return 0 ;
}

4.Run the Project

5.Save the file under bahagi

6.Compilation process.

7.Execute the program

8.Insert the data

9.Result

Вам также может понравиться