0% found this document useful (0 votes)
32 views

Programming C++ - Create 2 Simple Mathematic Operator Function Using C++ Software

The document summarizes how to create a simple C++ program that performs addition. It includes explanations of key C++ concepts used in the program such as #include directives, the main function, cout and cin for input/output, and return 0 to end the program successfully. It then provides step-by-step instructions for running the program, which involves creating a new source file, writing the code, compiling and running it, and inputting values to get the sum as output.

Uploaded by

Kenshin Himura
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Programming C++ - Create 2 Simple Mathematic Operator Function Using C++ Software

The document summarizes how to create a simple C++ program that performs addition. It includes explanations of key C++ concepts used in the program such as #include directives, the main function, cout and cin for input/output, and return 0 to end the program successfully. It then provides step-by-step instructions for running the program, which involves creating a new source file, writing the code, compiling and running it, and inputting values to get the sum as output.

Uploaded by

Kenshin Himura
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Question

1. Programming C++
- Create 2 simple mathematic operator function using C++
software.
Value of sum operation

Value of subtract operation

- Explain program C++ that you create (operation).


#
A hash sign are directive for the pre-processor.
#include
Lines beginning with a hash sign (#) are directive for the
preprocessor. The directive #include <iostream> tells the
preprocessor to include the iostream standart file.
Iostream.h
iostream.h is the C++ programming object inherit all
member from both instream (instream) and ostream. It
for perform both input and output operations.
Int main()
to beginning of the definition of the main function. The
function is the point by where all C++ program start their
execution,indepently of its location within the source
code.
Function
allow to structure program in segments of code to
perform individual tasks.

Cout
cout represent the standart output stream in C++ and the
meaning of the entire statement is insert a sequence of
character .
<<
the bitwise left shift to shift operator bits to the left.
\n
moves the active position to the initial position of the
next line.
;
the separation between statement is specified with an
ending semicolon at the end of each one sentences.
Return 0;
the return statement cause the main function to finish.
Return may be followed by a return code (in our example
is followed by return code 0). A return code of 0 for the
main function is generally interpreted as the program
worked as expected without any errors during its
execution.

- Give your answer step by step how to run that program.


1. Go to start >> all applications >> open programming C++

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

3. After that, click Console Application category to start the


project.

4. Write this program


#include <iostream>
#include <stdlib.h>
int main()
{
int X,Y,sum;
std::cout<<"\nEnter first number:";
std::cin>>X;
std::cout<<"\nEnter second number:";
std::cin>>Y;
sum=X+Y;
std::cout<<"\nSum = "<<sum;
system ("PAUSE");
return 0;
}

5. Compile the project by clicking the Execute tab and


choosing Compile and run or just press F11.

6. Wait until compilation process is finished

7. Execute the program

8. Insert the data

9. Result

10.

You might also like