+ 1

C programe to check prime number or not using if condition

15th Oct 2019, 1:50 PM
Yaseswini Depuru
Yaseswini Depuru - avatar
4 Answers
+ 2
step 1: ask user to input a number. step 2: (optional-but will be good) check if user input number is positive or not. step3: Iterate through all the numbers starting from 2 to (N/2) using aĀ for loopĀ and for every number check if it divides N. If we find any number that divides, we return false. If we did not find any number between 2 and N/2 which divides N then it means that N is prime and we will return True.
15th Oct 2019, 2:00 PM
ā˜…Ā«D.Connect_ZoneĀ»
ā˜…Ā«D.Connect_ZoneĀ» - avatar
+ 1
Why not use if-statements?
15th Oct 2019, 1:59 PM
Trigger
Trigger - avatar
+ 1
Ok also use if statements,I'm new to programming
15th Oct 2019, 1:59 PM
Yaseswini Depuru
Yaseswini Depuru - avatar
+ 1
I would suggest doing the C course on Sololearn and showing us your attempt first
15th Oct 2019, 2:00 PM
Trigger
Trigger - avatar