Make sure you have a compiler installed, for my case i used GCC. Usually, if its not installed, when you type the command "gcc -v" on the command line, you will get an error "gcc is not recognised as an internal or external command". If you get this error, even after installing the program, then try setting the environment variables as bellow;
- Open control panel
- Type "environment"
- Click to open "Edit the system environment variables for your account"
- Select PATH, then Edit
- In the edit section of variable value, add the path where your compiler is stored right after the termination (;)
- The path where your gcc compiler could be located in the directory "C:\MinGW\bin" or according to your customised path.
- On mine, since i had installed code blocks, its location was C:\Program Files (86)\CodeBlocks\MinGW\bi
- Open the command Line/Prompt
- Type "cd desktop" if your program is stored on the desktop Or navigate to the directory where your program is stored
- Type: gcc <fileName.c > e,g gcc loop.c This will compile your code and produce an executable with a name e.g a.exe because we never specified the name of our executable.
- You can name your file by following this structure; gcc -o <name_of_executable> <name_of_source_code
- Run the program by typing the executable file name on your command line E.g "a"
Here is the code i used
Bellow are the commands and the output
I love this
ReplyDeleteThanks 🙏🙏 alot
ReplyDeletewow
ReplyDeleteLike thumbs up
ReplyDeleteHi
ReplyDeleteGood stuff!
ReplyDeletewow
ReplyDeleteIt's impressive
ReplyDeletegood
ReplyDelete