下列程序的输出结果是()。 #include<stdio.h> main() {int a=2 b=3 p; p=f(a B) ; pdntf(\%d p);
程序
已帮助 人
下列程序的输出结果是()。
#include<stdio.h>
main()
{ int a=2,b=3,p;
p=f(a,B) ;
pdntf("%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
-
正确答案:A
解析:本题考查if else语句。在int f(a,b)中:第一个if语句,先判断条件,发现a>b条件不成立,则执行与其配对的else语句:第二个if语句,先判断条件,发现a==b条件不成立,则执行与其配对的else语句,c=-1。
