C++ Program Without main()


Q. Write a C++ program Without using main()?

#include <iostream>    
#define simple main
using namespace std;
  
int simple() 
{ 
	cout << "Welcome To Onlinetpoint"; 
	return 0; 
}

Q. Write an algorithm to Without using main()?

1. Start
2. Include necessary header files
    - Include the `iostream` header file to handle input-output operations.
3. Define a macro for the main function
    - Use `#define simple main` to replace the keyword `main` with `simple` in the code.
4. Use the standard namespace `std` so we can use `cout` without prefixing with `std::`.
5. Define the function `simple` (which is actually `main`)
    - Inside the function:
    - Print the message `"Welcome To Onlinetpoint"` on the console.
    - Return 0 to indicate that the program executed successfully.
6. End



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.