Professional Documents
Culture Documents
6
6
<<'\n' ;
return 0 ;
}
A program for finding the product in multiplication problems:
#include <iostream>
int main()
{
int v1, v2, range;
std::cout <<"Please input two numbers:"<< std::endl;
std::cin >> v1 >> v2;
if (v1<=v2)
{
range=v2-v1;
} else {
range=v1-v2;
}
std::cout <<"range = " << range << std::endl;
return 0;
}
A program for finding the value of exponents:
#include <iostream>
using namespace std;
int main()
{
int value, pow, result=1;
cout << "Please enter operand:" << endl;
cin >> value; #cout << "Please enter exponent:" << endl;
cin >> pow;
for (int cnt=0; cnt!=pow; cnt++)
result*=value;
cout << value << " to the power of " << pow << " is: " << result <<
endl;
return 0;
}
Create a Simple Program in C++ Step 23
Save this as a .cpp file with a name that accurately reflects your program.
Don't confuse there are many other extensions for C++ files, choose any of
them (like *.cc, *.cxx, *.c++, *.cp) .
HINT': It should say Save as Type: {select "All Files"}
Create a Simple Program in C++ Step 34
Compile it. For users of linux and gcc compiler, use Command : g++
sum.cpp. Users of Window can use any C++ compiler, such as MS Visual C+
+,Dev-C++ or any other preferred program.
Create a Simple Program in C++ Step 4