第二章总结

C语言程序中所用到的每一个常量、变量和函数等程序的基本操作对象都有一种数据类型与之相联系。 

数据类型

基本类型:整型、字符型、实型(浮点型)。

构造类型:数组类型、结构体类型、共用体类型、枚举类型。

指针类型。空类型。

常量是在程序执行过程中,其

#include<stdio.h>
#define PI 3.14159
void main()
{
    int r;
    float v, f;
    r = 2;
    v = 4.0 * PI * r * r * r / 3.0;
    f = 4.0 * PI * r * r;
    printf("体积为:%f,表面积:%f\n" ,v,f);

}

#include<stdio.h>
#define PRICE 20
int main()
{
    int num, total;
    num = 10;
    total = num * PRICE;
    printf("总价格为:%d\n", total);
    return 0;
}

#include<stdio.h>
int main()
{
    int a, b, c;
    char ch = 'A';
    a = 10;
    b = a + ch;
    scanf_s("%d", &c);
        printf("%d,%d,%d,%c\n", a, b, c, ch);
    return 0;

}


#include<stdio.h>
int main()
{
    int a, b, c, d;
    unsigned long e;
    a = 5; b = 6; e = 10;
    c = a + e;
    d = b + e;
    printf("c=%d,d=%d\n", c, d);
    return 0;

}

#include<stdio.h>
int main()
{
    short int a, b;
    a = 32767;
    b = a + 1;
    printf("a=%d,b=%d\n", a, b);
    return 0;
}

#include<stdio.h>
int main()
{
    float a = 1234.56789;
    double b = 1234.567895678;
    printf("a=%f,b=%f\n", a, b);
    return 0;
}

include<stdio.h>
int main()
{
    char cl,c2;
    cl = 'A';
    c2 = 65;
    printf("%c,%c\n",cl, c2);
    printf("%d,%d\n", cl, c2);
    return 0;
}

#include<stdio.h>
int main()
{
    char cl, c2;
    cl = 'A';
    c2 = 'B';
    cl = cl + 32;
    c2 = c2 + 32;
    printf("%c,%c\n", cl, c2);
    printf("%d,%d\n", cl, c2);
    return 0;
}

#include<stdio.h>
int main()
{
    int number, a ,b, c;
    number = 123;
    printf("输入的3位数为:%d\n", number);
    a = number / 100;
    b =(number-a * 100) / 10;
    c = number%10;
    printf("反序数是:%d%d%d\n", c, b, a);
    return 0;
}

#include<stdio.h>
int main()
{
    int i,j = 7;
    float k = 5;
    i = (j = j + 2, j/k);
    printf("i=%d\n", i);
    return 0;
}

#include<stdio.h>
int main()
{
    printf("char类型占%d字节\n", sizeof(char));
    printf("short int类型占%d字节\n", sizeof(short int));
    printf("int类型占%d字节\n", sizeof(int));
    printf("float类型占%d字节\n", sizeof(float));
    printf("double类型占%d字节\n", sizeof(double));
    return 0;
}

#include <stdio.h>


int main()
{
    int a, b;
    a = sizeof(3 + 5.0);
    b = sizeof 3 + 5.0;
    printf("%d,%d,%d\\", a, b, sizeof("china"));
    return 0;
}

#include <stdio.h>


int main()
{
    int a = 3, b = 4;
    float c;
    c = (float)(a + b) / 2;
    printf("c=%f\n", c);

    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值