A question that was asked to me few days ago..
After a long time, I wrote a code in C programming language..
This is the code for that process.
//Because it says that smaller than 100 in question
//if it is prime, isPrime will be 1 (to mean it is true)
//the variable ‘div’ is used to check numbers smaller than our current number if they are divisible or not
//if it can be divided, then the remainder will be zero
//if it is divided, current number is not a prime number
//(the -break- line) if it is divisible by any number, we don’t need to check the others
//if our number didn’t divide by any number above, then it is prime
//we add it to the end of the array (of found primes) and increment to number of total numbers found
//we increment -current- to check next number
//I used div as a temporary loop variable here
// I printed out the _div+1_ because the array starts from zero
//If you ask -why is the array for 50 integers?- I thought that there is 50 odd numbers and most of them are not prime. I continued, let’s take as if all of them are prime, there will be 51 ( because the only even prime number is 2. (50+1)). Then array of 50 will be enough… You can also see if you compile it, there is 25 prime numbers…