测试自动类型转换

#include stdio.hint main(void){char ch;//int i;float fl;fl = i = ch = C;printf(ch = %c, i = %d, fl = %2.2f\\n, ch, i, fl);

编程学习网为您整理以下代码实例,主要实现:测试自动类型转换,希望可以帮到各位朋友。

#include <stdio.h>

int main(voID){
    char ch;//
    int i;
    float fl;

    fl = i = ch = 'C';                                  
    printf("ch = %c, i = %d, fl = %2.2f\n", ch, i, fl); 
    ch = ch + 1;                                        
    i = fl + 4 * ch;                                    
    fl = 2.0 * ch + i;                                  
    printf("ch = %c, i = %d, fl = %2.2f\n", ch, i, fl); 
    ch = 107;                                          
    printf("Now ch = %c\n", ch);                        
    ch = 81.89;                                         
    printf("Now ch = %c\n", ch);                        

    return 0;
}

本文标题为:测试自动类型转换

上一篇: const关键字
下一篇: 产生20个随机数

基础教程推荐