A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Hello @Prabhjoat Riyat ,
The CommandNotFoundException errors you are seeing happen because the hello_world.exe file does not exist in your folder. The initial g++ compilation step failed silently in your first command, so the executable was never created.
Also, as a side note for PowerShell: you cannot run an executable just by typing its name (like hello_world.exe). You must prefix it with .\ or ./ (like you did in your last attempt). But again, it failed because the file wasn't there.
So, I suggest 2 approaches that you can fix this:
1. Fix your g++ command-line setup
- Check your compiler: Open PowerShell and type
g++ --version. If it returns an error (red text), it meansg++is either not installed or not added to your Windows Environment Variables (PATH). You will need to install MinGW/MSYS2 and configure the PATH. - Compile manually: Once
g++is properly installed, run the compile command alone so you can see if there are any code errors:g++ hello_world.cpp -o hello_world.exe - Run the program: If step 2 produces no errors, the
.exefile is successfully created. You can now run it:.\hello_world.exe
2. Use Visual Studio
As Viorel pointed out, since you are taking the "Microsoft C++ Course", the curriculum is likely designed around Visual Studio, not g++.
Instead of manually configuring compilers and typing commands, I recommend downloading Visual Studio Community. Install the "Desktop development with C++" workload, open your .cpp file there, and simply press Ctrl + F5 (or the green Run button). It will automatically compile and run the program for you without these PowerShell path issues.
I hope this helps with your question. If you found this informative, please consider providing feedback following this guide.
Thank you.