C语言(6)

1.二进制数据的转换自己百度(很简单)

2.简单的C程序:

#include<stdio.h>


int main(void)
{
        printf("hellowoarld!\n");

        return 0;
}
~   

3.常量:%s,%f,%d,%c

  1 #include<stdio.h>
  2 
  3 
  4 int main(void)
  5 {
  6 
  7         printf("%s,%d,%f,%c\n","hellowporld",12,3.34,'a');
  8         return 0;
  9 }

4.变量:

   1 #include<stdio.h>
  2 
  3 
  4 int main(void)
  5 {
  6 
  7         //整形变量  int
  8         /*变量命名:数字,字母和下划线组成,
  9          字母或下划线开头                               
 10         */
 11         int num1 = 5;
 12         int num2,res;
 13         num2 = 10;//赋值运算符=
 14         printf("num1:%d,num2:%d\n",num1,num2);
 15 
 16         res = num1 + num2;
 17         printf("%d + %d=%d\n",num1,num2,res);
 18 
 19         res = num1 - num2;
 20         printf("%d - %d=%d\n",num1,num2,res);
 21 
 22         res = num1 * num2;
 23         printf("%d * %d=%d\n",num1,num2,res);
 24 
 25         res = num1 / 3;
 26         printf("%d / %d=%d\n",num1,3,res);
 27 
 28         res = num2 % num1;
 29         printf("%d %% %d=%d\n",num2,num1,res);
 30         return 0;
 31 }

5.浮点数

#include<stdio.h>

int main(void)
{
        float n1,n2;//单精度浮点类型
        double n3,n4;//双进度浮点类型
        n1 = 2.35;
        n2 = 3.14;
        printf("n1:%g,n2:%g\n",n1,n2);

        n3 = 56.3;
        n4 = 87.66;
        printf("n3:%g n4:%g\n",n3,n4);
        return 0;
}
~   

6.字符型

  1 #include<stdio.h>
  2 
  3 int main(void)
  4 {
  5         //字符类型
  6         char ch,ch2;
  7         ch = 'a';
  8         printf("ch:%c\n",ch);
  9         ch2 = '\n';
 10         ch2 = '2';//注意字符类型和对应的数字类型
 11         printf("%c %d",ch2,2);
 12         
 13         return 0;
 14 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

weixin_41392061

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

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

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

打赏作者

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

抵扣说明:

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

余额充值