- 1
Need help with switch in swift
var a=2 switch a { case 2,3,5,7,11: print("the given number is prime number") fallthrough case 2,4,6,8,10: print("the given number is even also") case 1,3,5,7,9: print("the given number is odd number also") default: print("invalid number") } here in this program i want to print if the number is 2 it should print its a prime and even number and if i enter 3 it should reply the number is prime and odd number ..plz any one tell me wht i should chabge in it ...i want to do it by only using switch statement
1 Answer
+ 6
Then I think do it separately in two switch-case loops