+ 2
What is the difference between algorithm and program?
3 Respostas
+ 2
In simple terms, an algorithm is a finite set of unambiguous instructions to solve a problem. An algorithm is usually written in pseudo-code(i.e. a mixture of a natural language like English and high-level programming language)
e.g. Following is an algorithm to add two numbers
step 1)declare a variable(say a) and initialize it
step 2)declare another variable(say b) and initialize it.
step 3)add both the variables and print it
A program is a set of instructions given to CPU to perform a particular task. Progam is written in either high-level language like Java, C etc or low-level languages like binary and assembly.
Programmers usually prepare an algorithm first and then implement it using any programming language.
e.g.)Following is Java program based on the above algorithm
public class Main {
public static void main(String args[]) {
int a = 10;//declaring and initializing
int b = 20;//declaring and initializing
System.out.println(a + b);
}
}
0
Your brain is the program.
As you created this question, your thinking is the algorithm, as you stepped through the words you chose to construct your sentences.
Note: your brain would be hardware and your thinking would be software, but I changed it to fit the analogy above.
0
In simple terms, an algorithm is a finite set of unambiguous instructions to solve a problem. An algorithm is usually written in pseudo-code(i.e. a mixture of a natural language like English and high-level programming language)
e.g. Following is an algorithm to add two numbers
step 1)declare a variable(say a) and initialize it
step 2)declare another variable(say b) and initialize it.
step 3)add both the variables and print it
A program is a set of instructions given to CPU to perform a particular task. Progam is written in either high-level language like Java, C etc or low-level languages like binary and assembly.
Programmers usually prepare an algorithm first and then implement it using any programming language.
e.g.)Following is Java program based on the above algorithm
public class Main {
public static void main(String args[]) {
int a = 10;//declaring and initializing
int b = 20;//declaring and initializing