C++ 基本运算

博主分享了自己14年后重新学习C++的经历,打算深入探讨C++的基本运算和概念。
摘要由CSDN通过智能技术生成

距离第一次认识C++,已经过去了14年有余。重温之。

 

#include <stdio.h>

void basicNumberTypes()
{
    int n1 = 1378;
    short n2;
    char c = 'a';
    double d1 = 7.809;
    double d2;
    n2 = c;  // n2 = 'a'
    printf("c = %c, n2 = %d\n", c, n2);  // c = a, n2 = 97, ASCII(a)=97
    c = n1;  // c = 1378 => 0x562 
    printf("c = %c, n1 = %d\n", c, n1);  // c = b, n1 = 1378, 0x62 => 98, ASCII(b) = 98
    n1 = d1; // n1 = 7
    printf("n1 = %d\n", n1);  // n1 = 7
    d2 = n1;
    printf("d2 = %f\n", d2);  // d2 = 7.000000

    // Thinking 1.3.1
    char caesarCipher = 'a';
    int iCaesarCipher = caesarCipher;
    printf("result = %c", iCaesarCipher + 4);
}

void numbers()
{
    int a = 10;
    int b = 3;
    double d = a / b;
    printf(&#
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值