0
Coding interview questions
Write a Program to check whether a number is prime or not.
2 odpowiedzi
+ 6
Steps:- Suppose the number is user input, now set a loop(either for or while) that runs from 2 to input-number/2 or input-number-1(to avoid 1 as every number is divisible of 1).Define a Boolean variable and set it's value as true as default value and change its value to false if the loop find any number that is divisible of user input.(Note, define the Boolean variable outside the loop).
+ 1
Show us your work, we'll help you out.