How do I determine if a value is within a range?

前端 未结 1 1445
耶瑟儿~
耶瑟儿~ 2021-01-27 06:09

I am relatively new to C, I have to do it for school unfortunately and I am having issues with it at the easiest exercises.

Here I have to check if a number is in a cert

相关标签:
1条回答
  • 2021-01-27 06:47

    It is because you have declared i variable as int and you are taking input as string so when it is checking condition it is getting null value in i variable and not able to enter if block check below code

        #include <stdio.h>
    
        int main(){
    
          int i;
            printf("Value to check Interval \n");
            scanf("%d",&i);
    
          if (i>4 && i<6){
            printf("%d Value is in first interval\n", i);
          }
        }
    

    try compiling your code without if condition i variable will return a null value

    0 讨论(0)
提交回复
热议问题