学习c语言编程用什么软件_用C编程

学习c语言编程用什么软件_用C编程用c编程操作解析pdf文件WewouldstartwritingbasicprogramsinCnow.Youneedtohaverequiredsoftwareinstalledandconfiguredinyou

学习c语言编程用什么软件

We would start writing basic programs in C now. You need to have required software installed and configured in your system. Refer to the article of Hello World and ensure that you are able to compile and run the program.

我们现在就开始用C编写基本程序。 您需要在系统中安装和配置必需的软件。 请参阅Hello World的文章,并确保您能够编译和运行该程序。

了解基本语法 (Understanding the basic syntax)

Syntax is basically the grammar or arrangement of words in language. Not every detail is explained at his point to keep things simple but necessary things are covered. Look at the program given below

语法基本上是语言中的语法或单词排列。 在他的观点上,并不是每个细节都得到解释以使事情简单,但是涵盖了必要的事情。 看下面给出的程序

#include <stdio.h>
void main()
{
    printf("Hello World");
}
  1. #include <stdio.h>

    #include <stdio.h>

  2. In simple words, understand the above line as instruction to compiler “Hey C compiler, Include(or refer to) this stdio.h file when you are compiling the source code, so that you can understand the meaning of words and functions used such as printf(), scanf() etc.”
    It is because stdio.h file is present with compiler which has meaning(definition) of various functions defined in it which are frequently used.

    简而言之,请将上一行理解为对编译器的说明: “嘿,C编译器在编译源代码时包含(或引用)此stdio.h文件,以便您可以理解所用单词和函数的含义,例如printf(),scanf()等。”
    这是因为stdio.h文件随编译器一起提供,该文件具有其中定义的各种常用功能的含义(定义)。

  3. void main()

    无效main()

  4. It is the point from where execution of program starts. If there is no main(), there is no output.
    void is a return type which you will understand later with concept of functions.
    The curly braces (curly brackets ” { } “) define the scope, i.e. the functioning code should be within these braces to make it work.

    从此处开始执行程序。 如果没有main() ,则没有输出。
    void是一个返回类型 ,您稍后将通过函数的概念来了解它。
    花括号(花括号“ {}”)定义了范围,即功能代码应在这些花括号内以使其起作用。

用C编程 (Programming in C)

Now we’ll begin by writing few basic programs in C and understand the syntax and working in Sequential Flow.

现在,我们将开始用C编写一些基本程序,并了解语法并在Sequential Flow中工作。

  • Add 2 Numbers

    加2个数字

#include <stdio.h>int main(){    //Declaring Identifiers(variables)    int num_a;    int num_b;    int num_result;    //Take input from user when program is running    printf("Enter a value of num_a: ");    scanf("%d",&num_a);    printf("Enter a value of num_b: ");    scanf("%d",&num_b);    //Adding numbers and assigning to identifier    num_result = num_a + num_b;    //Printing result as Output    printf("Sum is %d", num_result);}

Output

输出量

Add-2-Numbers

Add-2-Numbers

加2-数字

  • Swap 2 Numbers

    交换2个号码

  • It swaps the values in 2 variables using a third variable.

    它使用第三个变量交换2个变量中的值。

    #include 
    
    int main()
    {
        int num_a;
        int num_b;
        int num_temp; //Temporary variable used for swapping.
    
        printf("Enter a value of num_a: ");
        scanf("%d",&num_a);
    
        printf("Enter a value of num_b: ");
        scanf("%d",&num_b);
    
        //Assigning value of num_a in num_temp variable.
        num_temp = num_a; //num_a and num_temp has same value
        //Assigning value of num_b into num_a
        num_a = num_b;
        //Assigning value of num_temp which has original value of num_a to num_b
        num_b = num_temp;
    
        //Printing Output
        printf("Value of num_a: %d", num_a);
        printf("\n"); //To print next output in next line
        printf("Value of num_b: %d", num_b);
    }

    Output

    输出量

    Swap-2-numbers

    Swap-2-numbers

    交换2位数字

    作业 (Assignments)

    Note: Try solving these on your own before searching for solutions on internet. These are very simple assignments. Assignment 5 to 8 are optional at this point.

    注意:在互联网上搜索解决方案之前,请尝试自行解决这些问题。 这些是非常简单的任务。 此时,分配5到8是可选的。

    1. Implement programs using arithmetic operators

      使用算术运算符实现程序

    2. Add
      Subtract
      Multiply
      Divide
      Remainder


      减去

      划分

    3. Find the last digit of given integer input

      查找给定整数输入的最后一位

    4. Input: 4857
      Output: 7
      Hint: Modulus Operator

      输入:4857
      输出:7
      提示:模运算符

    5. Use Increment and Decrement Operators

      使用递增和递减运算符

    6. Use Next Line Character (“\n”) to print “Hello World” in 2 lines

      使用下一行字符(“ \ n”)分两行打印“ Hello World”

    7. Also check what happens with “\t” character.

      同时检查用“ \ t”字符会发生什么。

    8. Print “Hello World” with Double Quotes included in Output

      打印输出中包含双引号的“ Hello World”

    9. use sizeof() operator and understand it’s functionality

      使用sizeof()运算符并了解其功能

    10. Swap 2 numbers without using 3rd variable

      交换2个数字而不使用第三个变量

    11. Find ASCII code of various characters

      查找各种字符的ASCII码

    摘要 (Summary)

    We have understood the basic syntax of programming in C. It is highly recommended to complete the assignments mentioned above to get a better hands on of programming before proceeding further. These basics are extremely important in order to do programming in any language.

    我们已经了解了C语言中编程的基本语法。强烈建议您完成上述任务,以便在继续进行之前更好地进行编程。 这些基础对于使用任何语言进行编程都非常重要。

    翻译自: https://www.journaldev.com/27950/programming-in-c

    学习c语言编程用什么软件

今天的文章学习c语言编程用什么软件_用C编程分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/62814.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注