#include <iostream>
int main()
{
cout << "Hello World!\n\n";
system("pause");
}
Now you can add a parameter and ask the user to enter a number, then display that number:
#include <iostream>
int main(int x) // The parameter(s) for the main function are x
{
cout << "Enter a number: ";
cin >> x; // Stores the input by the user to x
system("cls"); // Clears the CMD Promt window
cout << "Your number: " << x << "\n\n"; // Displays x
system("pause");
}
If you are asking the user for a hex value you would do this (This is the same as above just allows the user to enter a hex value)
#include <iostream>
using namespace std;
int main(int x) // The parameter(s) for the main function are x
{
cout << "Enter a number: ";
std::cin >> hex >> x; // Stores the input by the user to x
system("cls"); // Clears the CMD Promt window
cout << "Your number: "<< hex << x << "\n\n"; // Displays x
system("pause");
}
If you don't use the namespace std and use the second code in this tutorial and the user enters a hex value the program will close.
END TUTORIAL


Sign In
Create Account

Back to top









