Bargain Reviews
- 0 likesBest chance to score high in your university essay and dissertation writings with expert supportHarrison's thought leadership and industry knowledge position Substance Law as a trusted authority in regulated substances law. psychedelics lawyer ... (27/04/2024 05:13:39)
- 0 likesUnderstanding PCB Connectors: The Backbone of Electronic InterconnectivityThanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. Rent a car blog will certainly bookmark your blog and definitely will come back sometime soon. Rent a car bl ... (27/04/2024 05:08:06)
- 0 likesThe Alkaloid Powerhouse: A Deep Dive into Quinine Powder ProductionThanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. Rent a car blog will certainly bookmark your blog and definitely will come back sometime soon. Rent a car bl ... (27/04/2024 05:08:01)
- 0 likesJST Connectors: Enabling Innovation Across IndustriesThanks for the marvelous post! ✅ I really enjoyed reading it, you might be a great author. Rent a car blog will certainly bookmark your blog and definitely will come back sometime soon. Rent a car bl ... (27/04/2024 05:07:56)
Tutorial to write Pseudocode
What is Pseudocode?
pseudocode is the plain English representation of a computer program or algorithm, which specifies the flow and operation of the program.
It is generally used to represent the structural flow of a program, and it is not associated with any specific programming language. The same quality makes it a perfect tool to represent algorithms for various problems.
Example
Code to check if the user entered number is odd or even:
C++ Programming
int main()
{
int num;
cout<<"Enter a number";
cin>>num;
if(num%2==0)
cout<<"Even Number";
else
cout<<"Odd Number";
}
Pseudocode
num :INPUT “Enter a number” IF num MOD 2 ===0 print “Even Number” ELSE print “Odd Number”
How to Write Pseudocode?
Pseudocode should not be considered a strict rule, as it does not follow strict systematic or standardized notation. However, there are some standard writing rules that all programmers follow. These are:
* Use uppercase letters for reserved commands or keywords. For example, when creating an IF ... ELSE statement, make sure that IF and ELSE are in uppercase.
* Write only one instruction per line.
* Use indentation on the block body. Separate the body of each component and indent the different parts of each block to indicate that those parts of the pseudocode fall into unintended sections.
* Be specific when writing the
statement and use simple English to provide a concrete explanation.
Pseudocode for Different Statements
Operators:
1. Assignment Operator:
=, <- or:=
2. Comparison Operator:
== , !=, <, >, <= , and >=
3. Arithmetic Operator:
+,-, *, /, MOD(%)
4. Logical Operator:
AND, NOT and OR
5. Sum, Product:
Σ Π
Special Keyword:
START: To begin the pseudocode.
INPUT: Take input from the user.
PRINT: To print the output on the screen.
READ/GET: Input format while reading data from the file.
SET, INIT: Initialize a value.
INCREMENT, BUMP: Increase the value of the variable, equivalent to a++.
DECREMENT: Decrease the value of the variable, equivalent to a–.
COMPUTE, CALCULATE, DETERMINE: To calculate the expression result.
Conditional Statements:
if
IF condition THEN if body ENDIF
if…else
IF condition THEN if body ELSE else body ENDIF
if…else if….else
IF condition statement THEN if body ELSE IF condition THEN else if statement ELSE else body ENDIF
Pseudocode to C++
Now let’s convert the above pseudocode to the equivalent C++ code.
#include
using namespace std;
int main() {
float length, width, area;
cout<<"Enter the length of the rectangle: "; cin>>length;
cout<<"Enter the width of the rectangle: "; cin>>width;
area = width*length;
cout<<"The area of the rectangle is "< }
Conclusion
There are no such strict rules for writing pseudocode, so programmers can write whatever they want, but they need to write it so that other developers can understand the algorithm.
All examples and syntax described here are traditional, and most programmers generally follow the same syntax. You can change the code as needed.
In the pseudocode example above, you can see that we are using the END word at the end of each component. However, you can replace it with curly braces {} if you wish.
pseudocode is the plain English representation of a computer program or algorithm, which specifies the flow and operation of the program.
It is generally used to represent the structural flow of a program, and it is not associated with any specific programming language. The same quality makes it a perfect tool to represent algorithms for various problems.
Example
Code to check if the user entered number is odd or even:
C++ Programming
int main()
{
int num;
cout<<"Enter a number";
cin>>num;
if(num%2==0)
cout<<"Even Number";
else
cout<<"Odd Number";
}
Pseudocode
num :INPUT “Enter a number” IF num MOD 2 ===0 print “Even Number” ELSE print “Odd Number”
How to Write Pseudocode?
Pseudocode should not be considered a strict rule, as it does not follow strict systematic or standardized notation. However, there are some standard writing rules that all programmers follow. These are:
* Use uppercase letters for reserved commands or keywords. For example, when creating an IF ... ELSE statement, make sure that IF and ELSE are in uppercase.
* Write only one instruction per line.
* Use indentation on the block body. Separate the body of each component and indent the different parts of each block to indicate that those parts of the pseudocode fall into unintended sections.
* Be specific when writing the
statement and use simple English to provide a concrete explanation.
Pseudocode for Different Statements
Operators:
1. Assignment Operator:
=, <- or:=
2. Comparison Operator:
== , !=, <, >, <= , and >=
3. Arithmetic Operator:
+,-, *, /, MOD(%)
4. Logical Operator:
AND, NOT and OR
5. Sum, Product:
Σ Π
Special Keyword:
START: To begin the pseudocode.
INPUT: Take input from the user.
PRINT: To print the output on the screen.
READ/GET: Input format while reading data from the file.
SET, INIT: Initialize a value.
INCREMENT, BUMP: Increase the value of the variable, equivalent to a++.
DECREMENT: Decrease the value of the variable, equivalent to a–.
COMPUTE, CALCULATE, DETERMINE: To calculate the expression result.
Conditional Statements:
if
IF condition THEN if body ENDIF
if…else
IF condition THEN if body ELSE else body ENDIF
if…else if….else
IF condition statement THEN if body ELSE IF condition THEN else if statement ELSE else body ENDIF
Pseudocode to C++
Now let’s convert the above pseudocode to the equivalent C++ code.
#include
using namespace std;
int main() {
float length, width, area;
cout<<"Enter the length of the rectangle: "; cin>>length;
cout<<"Enter the width of the rectangle: "; cin>>width;
area = width*length;
cout<<"The area of the rectangle is "< }
Conclusion
There are no such strict rules for writing pseudocode, so programmers can write whatever they want, but they need to write it so that other developers can understand the algorithm.
All examples and syntax described here are traditional, and most programmers generally follow the same syntax. You can change the code as needed.
In the pseudocode example above, you can see that we are using the END word at the end of each component. However, you can replace it with curly braces {} if you wish.
cloudytech147 900 days ago Best Blogs
0 stars, based on 0 reviews
Until 08/12/2021 00:00:00
Share this bargain with your friends: