2020-11-11

C primer plus基础学习

函数多个变量的使用

/* 
fathoms convert to feet
*/
#include<stdio.h>
int main(void)
{
    int feet fathoms;    //int feet; int fathoms;
    fathoms=2;
    feet=6*fathoms;
    printf("there is %d feet in %d fathoms.\n",feet,fathoms);
    printf("Yes,I said %d feet!\n",6*fathoms);    //变量可由表达式替换
    return 0;
}
  • 开头需加注释,方便理解该程序作用;
  • 变量名称选择时应选择改变量的英文单词简写,易理解;
  • 不同的功能模块用空格来替换,便于阅读;
  • 每条语句占一行;

函数的定义

#include<stdio.h>
int main(void)
{
    printf("Rick,what are you doing?\n");   //Dad said
    answer();     //son answer
    printf("OK,Come here,I need your help!\n");
    return 0;
}
  • C代码的入口是main函数
  • 在main函数中使用到的函数,应该在主函数之后定义,在主函数之前声明
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Moring_w

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值