How to write a program in notepad (with pictures)

Table of contents:

How to write a program in notepad (with pictures)
How to write a program in notepad (with pictures)
Anonim

This article will show you how to write a program in the standard Windows Notepad application. In short, you will need to enter the program code into Notepad line by line, and then save the file in the format of the required programming language.

Steps

Part 1 of 6: General guidelines

Understandthis
Understandthis

Step 1. Familiarize yourself with the limitations of Notepad

Formally, you can write a program in Notepad in any programming language, but to run it, the program must be saved in the correct format.

Notepad files are saved as text documents by default

Make a Program Using Notepad Step 2
Make a Program Using Notepad Step 2

Step 2. Find and launch Notepad

The easiest way to launch Notepad is to open the Start menu

Windowsstart
Windowsstart

, type notepad, and then click on the blue Notepad icon at the top of the Start menu.

Programlanguage
Programlanguage

Step 3. Select a programming language

Notepad has no restrictions in programming languages, but for the program to work correctly, you will have to use the same language throughout the document.

If you don't know any programming language, use one of the examples provided in the article

Make a Program Using Notepad Step 4
Make a Program Using Notepad Step 4

Step 4. After completing the line of code, press ↵ Enter

As with most code editors, individual lines of code should be located on separate lines of Notepad.

Make a Program Using Notepad Step 5
Make a Program Using Notepad Step 5

Step 5. Close all open curly and square brackets

If you open brackets or braces (

{

or

[

), it must be closed to complete the line of code. Failure to follow this rule will result in errors in your code.

Considerusing
Considerusing

Step 6. Consider using a dedicated code editing program

While you can certainly write entire programs in Notepad, the reality is not that simple. Since Notepad does not have syntax highlighting and automatic markup, it is poorly suited for writing large chunks of code.

Notepad ++ is a free and more convenient option for working with code

Part 2 of 6: Creating a Program

Make a Program Using Notepad Step 7
Make a Program Using Notepad Step 7

Step 1. Launch Notepad

Notepad allows you to create and save any program, regardless of the programming language used.

Make a Program Using Notepad Step 8
Make a Program Using Notepad Step 8

Step 2. Enter the program code

Make sure to use the same programming language throughout the document.

Make a Program Using Notepad Step 9
Make a Program Using Notepad Step 9

Step 3. Click on File in the upper left corner of the Notepad window to expand the drop-down menu

Make a Program Using Notepad Step 10
Make a Program Using Notepad Step 10

Step 4. Click on Save As … at the top of the drop-down menu to open the Save As window

Make a Program Using Notepad Step 11
Make a Program Using Notepad Step 11

Step 5. Specify the folder to save

Click on a folder (for example, "Desktop") on the left side of the "Save" window to select it as the location of the program.

Make a Program Using Notepad Step 12
Make a Program Using Notepad Step 12

Step 6. Click on the File Type field at the bottom of the Save window to expand the drop-down menu

Make a Program Using Notepad Step 13
Make a Program Using Notepad Step 13

Step 7. Select All Files from the drop-down menu

This will allow you to save the Notepad file as any type of program.

Make a Program Using Notepad Step 14
Make a Program Using Notepad Step 14

Step 8. Enter the name of the future program

Click on the "Filename" text box and enter a name for your program.

Make a Program Using Notepad Step 15
Make a Program Using Notepad Step 15

Step 9. Add an extension to the program name

To properly save a program, add a programming language extension dot and label immediately after the program name. Here is a list of the most common programming languages and their extensions:

  • batch file (BAT) -.bat;
  • Html -.htm;
  • Python -.py;
  • C ++ -.cpp.
  • For example, to save a batch file named "watermelon", enter watermelon.bat in the "Filename" field.
Make a Program Using Notepad Step 16
Make a Program Using Notepad Step 16

Step 10. Click on Save in the lower right corner of the window to save the program in the specified format

To run a program, double-click on it (you may be asked to select a program to open the file).

Part 3 of 6: Creating a Simple Batch File

Make a Program Using Notepad Step 17
Make a Program Using Notepad Step 17

Step 1. Launch Notepad

Try to create a program that runs another program on your computer using the scripting language (BAT).

Make a Program Using Notepad Step 18
Make a Program Using Notepad Step 18

Step 2. Enter the name of the executable file to display the Command Line

Enter cmd.exe into Notepad.

Make a Program Using Notepad Step 19
Make a Program Using Notepad Step 19

Step 3. Save the program

Be sure to have a.bat extension at the end of the file name.

Make a Program Using Notepad Step 20
Make a Program Using Notepad Step 20

Step 4. Double click on the batch file

This will open a command prompt window.

Part 4 of 6: Creating a Simple HTML Program

Make a Program Using Notepad Step 21
Make a Program Using Notepad Step 21

Step 1. Launch Notepad

If you want to create a web page, HTML is a great language for the job.

Make a Program Using Notepad Step 22
Make a Program Using Notepad Step 22

Step 2. Indicate that you will be using HTML

Enter

! DOCTYPE html

and press ↵ Enter.

Make a Program Using Notepad Step 23
Make a Program Using Notepad Step 23

Step 3. Add HTML tag

Enter into Notepad

html

and press ↵ Enter.

Make a Program Using Notepad Step 24
Make a Program Using Notepad Step 24

Step 4. Define the text section of the program

Enter into Notepad

body

and press ↵ Enter. This line indicates that a section of information (in this case, text) will appear later in the document.

Make a Program Using Notepad Step 25
Make a Program Using Notepad Step 25

Step 5. Add a title to the page

Enter into Notepad

Text

and press ↵ Enter, replacing the word “Text” with the page title.

  • For example, to create a page with the title "Hello!", Type in Notepad

    Hey

    .
Make a Program Using Notepad Step 26
Make a Program Using Notepad Step 26

Step 6. Add text to your page

Enter

text

and press ↵ Enter, replacing the word "text" with text data.

  • For example, if you enter into Notepad

    How are you?

    , the phrase "How are you?" will appear immediately after the title.
Make a Program Using Notepad Step 27
Make a Program Using Notepad Step 27

Step 7. Close the text section

Type and press ↵ Enter.

Make a Program Using Notepad Step 28
Make a Program Using Notepad Step 28

Step 8. Indicate the end of the HTML program

Enter.

Make a Program Using Notepad Step 29
Make a Program Using Notepad Step 29

Step 9. Review your program code

It should look like this:

  • Hey

  • How are you?

Make a Program Using Notepad Step 30
Make a Program Using Notepad Step 30

Step 10. Save the program

Make sure to select the.htm extension when saving.

Make a Program Using Notepad Step 31
Make a Program Using Notepad Step 31

Step 11. Double click on the HTML file to open it in your default browser

You may be prompted to select a program first. The title and text of the program will appear in a new browser tab.

Part 5 of 6: Writing a Simple Python Program

Make a Program Using Notepad Step 32
Make a Program Using Notepad Step 32

Step 1. Launch Notepad

With the "print" command in Python, you can display any text you want.

Make a Program Using Notepad Step 33
Make a Program Using Notepad Step 33

Step 2. Enter the "print" command

Enter into Notepad

print ("

… Make sure there are no spaces between characters.

Make a Program Using Notepad Step 34
Make a Program Using Notepad Step 34

Step 3. Add the text you want to display

Enter Hello !.

Make a Program Using Notepad Step 35
Make a Program Using Notepad Step 35

Step 4. Close the "print" command

Enter

")

to close the command.

Make a Program Using Notepad Step 36
Make a Program Using Notepad Step 36

Step 5. Your code should look like the following

  • print ("Hello!")

Make a Program Using Notepad Step 37
Make a Program Using Notepad Step 37

Step 6. Save the program

Make sure to select the.py extension when saving. Now the program can be opened in any Python editor.

Part 6 of 6: Writing a Simple C ++ Program

Make a Program Using Notepad Step 38
Make a Program Using Notepad Step 38

Step 1. Launch Notepad

In this example, we'll walk through creating a simple C ++ program that, when run, displays the phrase “Hello World!” On the screen.

Make a Program Using Notepad Step 39
Make a Program Using Notepad Step 39

Step 2. Add the name of the program

Enter followed by the name of the program (for example, "My first program"). Any text on a line that comes after two forward slashes will be displayed as normal text (not part of the program).

  • For example, to designate your program as "Program 1", enter in Notepad:

    // Program 1

    .
Make a Program Using Notepad Step 40
Make a Program Using Notepad Step 40

Step 3. Enter the preprocessor directive

Enter

# include

and press ↵ Enter. This command tells C ++ to run the following lines of code as a program.

Make a Program Using Notepad Step 41
Make a Program Using Notepad Step 41

Step 4. Declare the program function

Enter

int main ()

and press ↵ Enter.

Make a Program Using Notepad Step 42
Make a Program Using Notepad Step 42

Step 5. Add an open parenthesis

Enter into Notepad

{

and press ↵ Enter. The main program code will be enclosed between this open parenthesis and its closing pair.

Make a Program Using Notepad Step 43
Make a Program Using Notepad Step 43

Step 6. Enter the executable code of the program

Enter

std:: cout << "Hello World!";

and press ↵ Enter.

Make a Program Using Notepad Step 44
Make a Program Using Notepad Step 44

Step 7. Add a closing parenthesis

Enter

}

to terminate the executing code of the program.

Make a Program Using Notepad Step 45
Make a Program Using Notepad Step 45

Step 8. Review your program

It should look like this:

  • //The name of the program

  • #include

  • int main ()

  • {

  • std:: cout << "Hello World!";

  • }

9

  • Save the program.

    Don't forget to include the.cpp extension. The saved program can be run in any C ++ compiler.

    Make a Program Using Notepad Step 46
    Make a Program Using Notepad Step 46
  • Advice

    • C ++ and HTML are two of the most commonly used programming languages.
    • Most programs can be written in almost any programming language, although some languages are better suited for certain tasks (for example, HTML is ideal for creating web pages).

    Warnings

    Always check your code before you save it. Saving a faulty program can lead to problems with the standard compiler

    Popular by topic