possible assignment in condition (C)

后端 未结 2 375
鱼传尺愫
鱼传尺愫 2021-01-21 19:40

I have to find is the number \"a\" a two-digit odd. Mistake comes on if

#include 
main ()
{
    int a,k;
    int count=0;
    printf (\"input numb         


        
2条回答
  •  野的像风
    2021-01-21 20:16

    The error is here:

    if (k = 1 && count = 2)
    

    you probably meant:

    if (k == 1 && count == 2)
    

    = is an assignment. == is a comparison for equality.

    Also, the loop is not necessary. You can check if the number is two digits by checking if it's less than 100 and greater than or equal to 10.

提交回复
热议问题