c语言编程规范标准示例_带输出的C编程示例

c语言编程规范标准示例

C programming examples – This section contains solved c programming examples on various c language popular topics. Provided all examples have explanations and output on different user inputs. These programs are important for exams and interview prospective. Programs are all time favourite for computer science students, IT professionals and job seeking guys.

C编程示例 –本节包含有关各种C语言流行主题的已解决C编程示例 。 提供的所有示例都有说明,并在不同的用户输入上输出 。 这些程序对于考试和面试前的准备很重要。 程序一直是计算机科学专业学生,IT专业人员和求职者最喜欢的。

Available programs start from "Hello world" to very upper level, we guarantee you will love these set of programs and these programs will definitely help you to increase your programming skills.

可用的程序从“ Hello world”开始到更高级别,我们保证您会喜欢这些程序集,这些程序肯定会帮助您提高编程技能。

带有输出的可用C编程示例列表: (List of available C programming examples with output :)

在GCC Linux中编译,运行C程序 (Compile, Run C program in GCC Linux)
  1. Write program.

    编写程序。

  2. Save program with filename.c (suppose file name is test.c).

    使用filename.c 保存程序(假设文件名为test.c )。

  3. Compile program using command gcc test.c -o test

    使用命令gcc test.c -o test 编译程序

    Here test is the executable (binary) file name.

    这里的test是可执行文件(二进制)的文件名。

  4. Run file using command ./test

    使用命令./test 运行文件

在Turboc2 / TurboC3 Windows中编译,运行C程序 (Compile, Run C program in Turboc2/TurboC3 Windows)
  1. Write program.

    编写程序。

  2. Save program with filename.c (suppose file name is test.c).

    使用filename.c 保存程序(假设文件名为test.c )。

  3. Compile program by pressing ALT+F9.

    通过按ALT + F9 编译程序。

  4. If program is error free, Run program by pressing CTRL+F9.

    如果程序没有错误,请按CTRL + F9 运行程序

  5. See the output by pressing ALT+F5.

    通过按ALT + F5查看输出

编写好的编程代码的技巧 (Tips to write good programming code)
  1. Analyse the problem: many programmer start witting before analysing the problem, this is very bad habit, ignore this always analyse the problem by collecting information from concerned person.

    分析问题:许多程序员在分析问题之前就开始尝试,这是一个非常坏的习惯,忽略这一点总是通过从有关人员那里收集信息来分析问题。

  2. Make algorithm or flow chart: before writing code, make flow chart or algorithm of your logic and code through that.

    制作算法或流程图:在编写代码之前,先编写逻辑和代码的流程图或算法。

  3. Documentations: insert proper comments with function name, description, date and time, arguments details. Everything related to code must be there; it will help you or others to understand your code.

    文档:插入适当的注释,包括函数名称,描述,日期和时间,参数详细信息。 与代码相关的所有内容都必须存在。 它将帮助您或其他人理解您的代码。

  4. Indentations: Code that you had written must be in proper indentation, so that you can read or debug your code easily. Close all braces at the same indent as open. Always insert a tab when you write code within the block.

    缩进:您编写的代码必须使用适当的缩进,以便您可以轻松阅读或调试代码。 关闭所有大括号,使其与打开时相同。 在块中编写代码时,请始终插入标签。

  5. Define Macros: Always define macros for values, do not use values within the code, macros are easily editable and you can edit values whenever required without changing in the functions.

    定义宏:始终为值定义宏,不要在代码中使用值,宏易于编辑,您可以在需要时随时编辑值而无需更改功能。

  6. Initialize all data: Don’t do only declarations, try to assign initial values to them. For examples if you are declaring a variable to store age of the student. Declare with initialization like int age=0;

    初始化所有数据:不要仅进行声明,请尝试为它们分配初始值。 例如,如果您声明一个变量来存储学生的年龄。 用初始化声明,例如int age = 0;

  7. Use enumeration: Define enum for numerical literals instead of direct literal.

    使用枚举:为数字文字而不是直接文字定义枚举 。

  8. Make functions: always divide your code into small pieces (called function), it will help you to reduce duplicate and you can edit or debug code easily.

    生成函数:始终将代码分成小段(称为函数),这将帮助您减少重复,并且您可以轻松地编辑或调试代码。

  9. Don’t ignore warnings: Some programmers ignored warnings while compiling or running the programs. It is not good for program health a program must have 0 Error and 0 Warning.

    不要忽略警告:一些程序员在编译或运行程序时忽略了警告。 程序必须具有0错误和0警告,这不利于程序健康。

  10. Test your program with different inputs: to test program is logically correct or not, test it with different inputs and analyse the output.

    使用不同的输入测试程序要测试程序在逻辑上是否正确, 请使用不同的输入测试程序并分析输出。

翻译自: https://www.includehelp.com/c-programming-examples-with-output.aspx

c语言编程规范标准示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值