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

admin2010-09-05  23

问题 下列程序的输出结果是(    )。
   #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。
转载请注明原文地址:https://kaotiyun.com/show/CeWp777K
0

最新回复(0)