Hi In the "scanf" statement there is a space in your third %f (between % and f).
  Thats the cause.

[Mod - No there isn't - you may want to change your mail reader - PJH]

  The third value is taken as '0' because of the above mistake.
  Here is the outcome of the program (added a printf to print the values)

  Output With mistake:
  Enter three integer(larger than zero):1.1
1.0
2.0
  num_a:1.100000 num_b:1.000000 num_c:0.000000
can' t!Press any key to continue . . .

  Output after removing the mistake:
  Enter three integer(larger than zero):1.1
1.0
2.0
  num_a:1.100000 num_b:1.000000 num_c:2.000000
can! Press any key to continue . . .

  Below is the modified code

  
/**************************************************************************************/
  #include <stdio.h>
#include <stdlib.h>
  int main(int argc, char *argv[])
{
float num_a, num_b, num_c;
  printf("Enter three integer(larger than zero):");
scanf("%f%f%f", &num_a, &num_b, &num_c);
  printf("\nnum_a:%f num_b:%f num_c:%f\n",num_a, num_b, num_c);
if(
    ((num_a + num_b) <= num_c) ||
    ((num_a + num_c) <= num_b) ||
    ((num_b + num_c) <= num_a)
)
{
 printf("can' t!");
}
else
{
 printf("can! ");
}
  system("PAUSE");
  return 0;
}


"Zoro.MONKEY" <[EMAIL PROTECTED]> wrote:


the source file:

#include<stdio.h>
#include<stdlib.h>
int main()
{
float num_a, num_b, num_c;

printf("Enter three integer(larger than zero):");
scanf("%f%f%f", &num_a, &num_b, &num_c);

if(num_a + num_b <= num_c || num_a + num_c <= num_b || num_b + num_c <= num_a)
printf("can't!");
else
printf("can!");

system("pause");
return 0;
}
when I enter 2.3 2.4 and 4.7 ,the program print "can!", puzzle me....
who can tell me why....

from:陈婷婷


©网易公司版权所有

[Non-text portions of this message have been removed]






---------------------------------
 Yahoo! Answers - Get better answers from someone who knows. Tryit now.

[Non-text portions of this message have been removed]

Reply via email to