CPPForSchool.com: Flow of Control Set 2: Assignment 7
7.
Write a program to check given number is prime or not.
This assignment had me scratching my head for a long while. Conceptually, I understand what is prime number, specifically a number can only be divided by 1 and itself. However, when creating an algorithm to accomplish this, it was a bit over my head. At first, I created an algorithm to test if there were any remainders, but I was not sure how to code it so it recognizes that it had more that 1 and itself as an equal divider. With that shortcoming, I had no choice but to review the sample solution source code. It appears that I was heading into the right direction, but lacked the experience to properly execute the task.
Nevertheless, below is my source code and resulting outputs. Also, I have included the sample source and output for comparison.
This assignment had me scratching my head for a long while. Conceptually, I understand what is prime number, specifically a number can only be divided by 1 and itself. However, when creating an algorithm to accomplish this, it was a bit over my head. At first, I created an algorithm to test if there were any remainders, but I was not sure how to code it so it recognizes that it had more that 1 and itself as an equal divider. With that shortcoming, I had no choice but to review the sample solution source code. It appears that I was heading into the right direction, but lacked the experience to properly execute the task.
Nevertheless, below is my source code and resulting outputs. Also, I have included the sample source and output for comparison.
Comments
Post a Comment