current position:Home>If you don't use conditional judgment if a question, how to do it? Enter two numbers

If you don't use conditional judgment if a question, how to do it? Enter two numbers

2022-01-26 21:51:43 CSDN Q & A

If you don't use conditional judgment if What should I do if I have to
Enter two numbers a and b, Ask for judgment a whether Can be b to be divisible by , Out-of-service if




Refer to the answer 1:

Ternary operator .

#include <stdio.h>int main(){    int a=6,b=3;    int c=a%b==0?1:0;     if(c==1){        printf(" Can be divisible ");    }else{        printf(" Can't be divisible ");    }     return 0;}

img




Refer to the answer 2:



Refer to the answer 3:

It can be used ?: Ternary operator




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262151410825.html

Random recommended