<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # C 語言中的 Hello World 程序 > 原文: [https://beginnersbook.com/2017/09/c-hello-world-program/](https://beginnersbook.com/2017/09/c-hello-world-program/) 在這里,我們將編寫兩個 C 程序來在屏幕上顯示`Hello World`。在第一個程序中,我們使用`printf`函數顯示消息,在第二個程序中,我們調用用戶定義的函數,該函數在屏幕上顯示`Hello World`消息。 ## 示例 1:顯示`Hello World` ```c #include <stdio.h> int main() { /* printf function displays the content that is * passed between the double quotes. */ printf("Hello World"); return 0; } ``` 輸出: ```c Hello World ``` 1. `#include <stdio.h>` - 該語句告訴編譯器在程序中包含此`stdio.h`文件。這是一個標準輸入輸出文件,包含常見輸入輸出函數的定義,如`scanf()`和`printf()`。在上面的程序中,我們使用`printf()`函數。 2. `int main()` - 這里`main()`是函數名,`int`是這個函數的返回類型。每個 C 程序都必須具有此函數,因為程序的執行以`main()`函數開始。此函數的返回值 0 表示程序的成功執行,而返回值 1 表示程序的不成功執行。這就是我們在這個主函數末尾有`return 0;`語句的原因。 3. `printf("Hello World");` - 此函數在屏幕上顯示雙引號內的內容。 4. `return 0;` - 如上所述,值 0 表示成功執行`main()`函數。 ## 示例 2:帶有函數的`Hello World`程序 讓我們查看帶有用戶定義的函數的相同的程序。在這個程序中,我們創建了一個函數`hello()`,用于在屏幕上打印消息。我們在`main()`函數中調用此函數。要了解用戶定義的函數,請閱讀本指南:[C 中的用戶定義函數](https://beginnersbook.com/2014/01/c-functions-examples/) 。 ```c #include void hello(){ printf("Hello World"); } int main() { //Calling a function here hello(); return 0; } ``` 查看這些相關的 [C 程序](https://beginnersbook.com/2015/02/simple-c-programs/): 1. [C 程序:打印用戶輸入的號碼](https://beginnersbook.com/2017/09/c-program-to-print-an-integer-entered-by-a-user/) 2. [C 程序:檢查數字是偶數還是奇數](https://beginnersbook.com/2015/02/c-program-to-check-if-number-is-even-or-odd/) 3. [C 程序:以升序排列數字](https://beginnersbook.com/2015/02/c-program-to-arrange-numbers-in-ascending-order/)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看