您好,欢迎访问代理记账网站
移动应用 微信公众号 联系我们

咨询热线 -

电话 15988168888

联系客服
  • 价格透明
  • 信息保密
  • 进度掌控
  • 售后无忧

【不求甚解】《C Primer Plus》第三章 数据和C

示例程序

#include <stdio.h>

int main(void)
{
    float weight;
    float value;
    
    printf("Are you worth your weight in platinum?\n");
    printf("Please ener your weight in pounds: ");
    
    scanf("%f", &weight);
    value = 1700.0 * weight * 14.5833;
    printf("Your weight in platinum is worth $%.2f.\n", value);
    printf("You are easily worth that! If platinum prices drop,\n");
    printf("eat more to maintain your value.\n");
    
    return 0;
    
}

数据:数据类型关键字

最初 K&R 给出的关键字C90 标准添加的关键字C99 标准添加的关键字
intsigned_Bool
longvoid_Complex
short_imaginary
unsigned
char
float
double

C 语言基本数据类型

#include <stdio.h>

int main(void)
{
    int ten = 10;
    int two = 2;
    
    printf("Doing it right: ");
    printf("%d minus %d is %d\n", ten, 2, ten - two);
    printf("Doing it wrong: ");
    printf("%d minus %d is %d\n", ten);
    
    return 0;
}
#include <stdio.h>

int main(void)
{
    int x = 100;
    
    printf("dec = %d; octal = %o; hex = %x\n", x, x, x);
    printf("dec = %d; octal = %#o; hex = %#x\n", x, x, x);
    
    return 0;
}
#include <stdio.h>

int main(void)
{
    unsigned int un = 3000000000;
    short end = 200;
    long big = 65537;
    long long verybig = 12345678908642;
    
    printf("un = %u and not %d\n", un, un);
    printf("end = %hd and %d\n", end, end);
    printf("big = %ld and not %hd\n", big, big);
    printf("verybig = %lld and not %ld\n", verybig, verybig);
    
    return 0;
}
#include <stdio.h>

int main(void)
{
	char ch;
    
    printf("Please enter a character.\n");
    scanf("%c", &ch);
    printf("The code for %c is %d.\n", ch, ch);
    
    return 0;
}

分享:

低价透明

统一报价,无隐形消费

金牌服务

一对一专属顾问7*24小时金牌服务

信息保密

个人信息安全有保障

售后无忧

服务出问题客服经理全程跟进