C Language Programming "Let the computer Speak"

Source: Internet
Author: User

Why does a computer appear? Our great man, the invention of everything is to help us human beings, improve human life. Computers are also tools used to help us humans. Think about it, if you want the computer to help you do one thing right now, what do you need to do first? Do you have to communicate with the computer first? Then communication needs to depend on a language. Human communication can be used in body language, Korean, English, French and German. If you want to communicate with a computer, you need 11 computers to understand the language. We learn the "C language" is a computer language, computer language in addition to C language, there are C + +, Java, C # language and so on. C language is a relatively simple computer language more suitable for beginners. All computer languages are interlinked, and if you can master the C language skillfully, it is easy to learn other languages.

Since the computer is a human-made tool for human beings, it is very important to let the computer speak and let the computer tell us what it knows.

Here's our sister's first question: How to make a computer speak!

In retrospect, when we came to this world, what was the first word we said? Should not be "Hello!" "Did you eat it?" ”...... This will scare your mom and dad ー_ー!.

With the legacy of "WA wa wa" crying, we came to this wonderful world. Now we also let the computer to "cry once." This place specifically explains that computers have to tell humans what they want to say, in two ways, one that is displayed on the monitor screen and one that emits sound through the horn. Just like a human avocado, one is written on paper and one is spoken out of the mouth. We currently make the computer with speakers when the sound is still more troublesome, so we use another method, with the screen output "WA wa wa."

printf("wa wa wa");

Here is a strange word called printf, you do not be frightened by him, at present you do not understand its essential meaning is what, you just remember it good Chinese inside the "say", the English "say" is a meaning, is to control the computer to speak a word just. Behind printf is a pair of parentheses (), which is like a mouth, "put" in the "mouth" of what you want to say. There is also a need to note that in WA WA WA on both sides of a pair of double quotation marks "", the double quotation mark is the computer needs to say the content, this is not much like our Chinese, and finally, a sentence of the end of a sign to have an end. We use the period in Chinese. " "means the end of a word. English with the dot number "." Indicates the end of a sentence. In computer language, use a semicolon ";" Represents the end of a statement.

Note: Every word of the computer is a statement.

Well, now, if you want to write a statement to let the computer say "Ni Hao" what to do.

printf("ni hao");

We now let the computer run this statement, here to illustrate, just write printf ("Ni hao"), our computer is not recognized, need to add a framework. The complete program is as follows:

#include#includeint main(){printf("ni hao");return 0;}

Here's

#include#includeint main(){return 0;}

All C language must have a framework, now you do not need to understand it, anyway to have this is, and then come to detail here is what to do with. But one thing that we write in the future is that all statements like printf are written in this pair of {} to be effective.

Next we need to get the computer to run the program we just wrote.

If you let the computer run what we write. Need a special software called "C language Compiler".

First you need to download a VC6

Do not know how to download the children's shoes can add the penguin skirt: 710520381, numbered: Pick one, the skirt has the installation of the use of tutorials.

Once the installation is complete, we double-click

This software, open it,

Select "File"--"new"

In the list on the left, select "Win32 Console Application", which is the Win32 console project, the console is similar to the cmd window in Windows, just start programming, choose to create this project. Enter the project name on the right, I enter "Myfirstproject" Here, location Select a folder to hold the project, if not placed in the default path, then click on the right side of the display as "..." button, and then customize the selection path, I choose the path is F:\VC6\ Myfirstproject, then click OK, select "An empty Project" in the next dialog box, click Done, and click "OK" in the subsequent window that appears.



This time an empty project is created and our source code files will be included in this project. Click "FileView" and select "Source Files"

Then we start to create the source code file, click "File"-"new" in the upper left corner of the software, and then appear the dialog box that you just saw, select "File" in the label above, then select "C + + Source file" in the list below, file name Enter hello.c, then click " OK ".

When you're done, the edit area on the right will automatically open the blank hello.c file, and the workspace on the left can see the entire project's organizational structure.


Next we copy the previous code, press Ctrl+s to save, then press the button above the edit area to compile, link, and then execute

If your code is not written correctly, you will see the results displayed

If you want "Ni Hao" to be shown in two lines, you just need to change printf ("Ni hao") to printf ("ni \ Hao"), where \ n means "newline." Note that this is the bottom right corner of the tilt, his position on the keyboard, usually on the top of the Enter. The code is as follows:

#include#includeint main(){printf("ni\nhao ");return 0;}

C Language Programming "Let the computer Speak"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.