Programming #1



Introduction


In this report I like to discuss about algorithm, flow chart, pseudo code, programming language. I like to discuss those by an example. The example is I am going to create a program to find given number is a prime number or not. First I like to show this program step by step as an algorithm. And I am converting this into a flow chart. And also I am writing this program in pseudo code. Finally I am writing this program in a suitable programming language call java.

Algorithm

 

Definition of algorithm
                                    An algorithm is step by step method which we use to solve a problem.An algorithm is the best and suitable way to solve a problem easily. Why I am saying like this is an algorithm is in sequence method , that mean step by step. We can easily understand the program by the algorithm. Algorithm is the suitable way to solve a problem.
Building a suitable algorithm to test a given number is a prime number


  •   Get a suitable number
  •  Create a variable call (a ) and assign the value 2
  •  Check whether number is less than variable (a)
  •  If the number less than (a) than note that number as a prime number
  •  If the number is more than (a) than divide the number by variable(a) value
  •  If the there is no remainder(value 0) than note that number as not a prime number
  •  If the remainder value more than 0 than increase variable (a) value by 1


No comments:

Post a Comment