#includeusing namespace std; int main() { int num; cout << "Enter a number: "; cin >> num; cout << "You entered: " << num << endl; return 0; }
#includeusing namespace std; int main(int argc, char *argv[]) { cout << "You entered " << argc << " arguments:" << endl; for (int i=0; i < argc; i++) { cout << argv[i] << endl; } return 0; }
#includeIn this example, the program prompts the user to input some text and then writes it to a file named 'example.txt.' Package/Library: iostream, fstream#include using namespace std; int main() { string text; ofstream myfile; myfile.open ("example.txt"); cout << "Enter text: "; getline(cin, text); myfile << text; myfile.close(); cout << "Text written to file." << endl; return 0; }