+ 1
What is the code to show me which numbers are even or divisible by 3?
I need to know the C # code to show me which ones are even or divisible by 3
2 Antworten
+ 4
Use the modulo operator %
num % 2 == 0 // true if even false if odd
num % 3 == 0 // true if divisible by 3
+ 3
You need to find remainder and for that we use modulo operator ,
if number%3==0:
"divisible by 3"
if number%2==0:
"even number"