
The next level of programming in C++. Adding the two integer.
Below is a simple program in adding two integers:
#include<iostream> /* header */
int main ()
{
int number1; /* declaration */
std::cout << "Enter first integer: "; /* prompt */
std::cin >> number1; /* read the first integer */
int number2, sum; /* declaration */
std::cout << "Enter second Integer: "; /* second prompt */
std::cin >> number2; /* read the second integer */
sum = number1 + number2; /* adding two integer input */
std::cout << "Sum = " << sum << std::endl; /* print the sum */
return 0;
}

You can see that without declaring the std you will need to enter it in your statement.
std::cin >> - it is also means scanf in C.
0 comments:
Post a Comment