How to Make a Simple C Program

by Branden Sammons in Circuits > Software

17083 Views, 19 Favorites, 0 Comments

How to Make a Simple C Program

CMD4.PNG

These instructions will show you how to construct a very basic C program. Currently computers are found in almost every household in America and programming is a method that lets us interact directly with them. Thus I created this instruction for anyone with a windows computer to follow. People with no programming knowledge might spend 30 or so minutes, but those with more experience will take less time. By the end of the instruction you should have a working program that you constructed yourself.

Needed Things

  • Windows computer
    • Admin access may be needed
    • Adaptations can be made with other computers
  • Internet connection

Downloading Software

Website1.PNG
Website2.PNG
Website3.PNG
Note: If you are running a non windows computer this step and the one that follows won't pertain to you.

1. Click on this Link > MinGW

2. Click the Download link on the webpage

Figure 1
Note: You will be redirected to the page in Figure 2

3. Click the Download link on the new webpage

Figure 2
Note:You will be redirected to the page in Figure 3

4. Wait till the download completes

Figure 3
Note: Can take awhile

5. Navigate towards your computers downloads folder

Install the Software

Download1.PNG
Download2.PNG
Download3.PNG
Download4.PNG
Download5.PNG
Download6.PNG

1. Run the Installer

Note: you might run into a popup, just hit run as in Figure 4

2. Click on the Install button

Figure 5

3. Uncheck the Graphical User Interface box

Figure 6

4. Click the Continue button

Figure 7

5. Wait for the software to download

Figure 8

6. After the software has finished downloading click on the Quit button

Figure 9

Create the Code

notepad1.png
Code1.PNG
Code2.PNG
Code3.PNG
Code4.PNG
Code5.PNG
Code6.PNG

1. Open Notepad

Click the windows button then type "notepad" as in Figure 10
If done right should end up at Figure 11

2. Type the files to include

#include <stdio.h>
Figure 12
Note: You can add other files you would like to use, we will include this so that we can have output

3. Add the Main Statement and the brackets

int main( int argc, const char* argv[] ) {

}
Figure 13

4. Add the Printf Statement within the brackets

printf("Hello World! Made by [insert name].");
Figure 14
Note: replace [insert name] with your name for added personalization

5. Save the File as a .c file

Figure 15 then Figure 16

Compile and Run

CMD.png
CMD1.PNG
CMD2.PNG
CMD4.PNG

1. Open Command Prompt

Click the windows button then type "cmd" as in Figure 17
If done right should end up at Figure 18

2. Type in the GCC command

gcc First.c -o First
Figure 19

3. Type in the command to run the program

./First
Figure 20

Finished

There you have it you have constructed your first C program. Now adapting the simple code we constructed you can make more complex programs. If you experienced any problems try the MinGW webpage, there is a troubleshooting section. If that doesn't fix the problem try going over the instructions again. If neither of those help you try asking your questions on Stack Overflow.