• 2022-05-31
    若变量a,b已定义为int类型并赋值21和55,要求用printf函数以a=21,b=55的形式输出,完整的输出语句是
    A: printf("a=%d,b=%d",a,b;)
    B: printf("%d,%d",a,b;)
    C: printf("a=%f,b=%f",a,b;)
    D: printf("%f,%f",a,b;)
  • A

    内容

    • 0

      在C语言中,能使单精度浮点型变量f=2输出为2.00的语句是( )。 A: printf("%2f",f) B: printf("%2.0f",f) C: printf("%4.2f",f) D: printf("%f",f)

    • 1

      调用函数f(27)的输出结果是( )。void f(int n){ if(n<5)printf("%d", n); else{ printf("%d", n%5); f(n/5); }} A: 102 B: 201 C: 21 D: 20

    • 2

      以下关于字符变量或常量的计算,错误的是? A: 语句printf("%d", 'F' - 'B');的输出为:4 B: 语句printf("%c", 'F' - 3);的输出为:C C: 语句printf("hello\12world");的输出为:helloworld D: 有定义char a=10;语句printf("hello%cworld", a);的输出为:hello10world

    • 3

      如果float a=123.456,则输出123.456的语句是: A: printf("%e",a); B: printf("%f",a); C: printf("%g",a); D: printf("%.3f",a);

    • 4

      以下if语句语法正确的是() A: if(x>0)printf(“%f”,x)else printf(“%f”,-x); B: if(x>0){ printf(“%f”,x); }else printf(“%f”,-x); C: if(x>0);{ printf(“%f”,x); }else printf(“%f”,-x); D: if(x>0){ printf(“%f”,x) }else printf(“%f”,-x);