下列程序的输出结果是( )。 #include<stdio.h> main() { int a=2,b=3,p; p=f(a,b); printf("%d",p); } int f(a,b

admin2010-09-05  16

问题 下列程序的输出结果是(    )。    #include<stdio.h>    main()    {   int a=2,b=3,p;        p=f(a,b);        printf("%d",p);    }    int f(a,b)    {  int c;       if(a>b)c=1;       else if(a==b)c=0;       else c=-1;       return(c) ;    }

选项 A、-1
B、0
C、1
D、2

答案1

解析 本题考查if else语句。在int f(a,b)中:第一个if语句,先判断条件,发现a>b条件不成立,则执行与其配对的else语句;第二个if语句,先判断条件,发现a==b条件不成立,则执行与其配对的else语句,c=-1。
转载请注明原文地址:https://kaotiyun.com/show/HqWp777K
0

随机试题
最新回复(0)