+ 2

What is the difference between algorithm and program?

12th Nov 2019, 11:43 AM
Surbhi Gupta
Surbhi Gupta - avatar
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); } }
12th Nov 2019, 12:05 PM
Rishi Anand
Rishi Anand - avatar
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.
12th Nov 2019, 5:04 PM
Xyenia 🦉
Xyenia 🦉 - avatar
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
13th Nov 2019, 6:36 AM
Abdul Wahab Chattha
Abdul Wahab Chattha - avatar