Algorithms, Flowcharts and Applications Decide Odd-Even Numbers

Algorithms, Flowcharts and Applications Decide Odd-Even Numbers

Programming World – Right here I’ll share an entire rationalization of algorithm examples, flowcharts together with program examples from numerous programming languages ​​PHP, Python C++ and Java to find out odd and even quantity applications.

For these of you who’re in search of an understanding of what algorithms and flowcharts are, you’ll be able to learn tutorials about algorithms and flowcharts together with examples right here.

Algorithms, Flowcharts and Applications Decide Odd-Even Numbers

Earlier than we go right into a dialogue about algorithms, flowcharts and applications, let’s first perceive the which means of strange and even numbers.

Even Quantity: A quantity that’s divisible by 2 or is a a number of of two
Odd Quantity: A quantity that isn’t divisible by 2 or just isn’t a a number of of two

Instance:

  • Even numbers are divisible by 2: 2, 4, 6, 8, 10, 12, 14 and so on…

  • Odd numbers aren’t divisible by 2: 1, 3, 5, 7, 9, 11, 13 and so on…

Truly, you already perceive what odd and even numbers imply, however you do not have an image as a result of you aren’t aware of algorithms, flowcharts, particularly applications, due to this fact we have to perceive the idea first earlier than going into the method of engaged on algorithms, flowcharts, particularly applications.

Will this odd-even course of be utilized in a program?

The reply will certainly be used, that is the premise for you who will later encounter extra difficult program issues, so there is not any hurt if we be taught the fundamentals first.

Let’s go straight into discussing the method of making algorithms, flowcharts and applications in every programming language under.

Algorithm for Figuring out Odd or Even Numbers

The next is the move of the algorithm for figuring out odd and even numbers.

  1. Begin

  2. Declare a quantity variable

  3. Enter quantity worth (greater than 0)

  4. Test with the modulus to seek out out the rest of the quotient by 2

  5. If the modulus/the rest of the results of dividing a quantity by 2 is the same as 0 then it’s a good quantity, if it’s not equal to 0 then it’s an odd quantity

  6. Present Even or Odd standing

  7. Completed

The method above is the method of discovering the standing of the quantity entered, whether or not it’s an odd quantity or a good quantity.

Subsequent, we are going to focus on how the flowchart appears like.

Flowchart Figuring out Odd or Even Numbers

The next is an instance of a flowchart for figuring out odd and even numbers.

Flowchart Figuring out Odd-Even Numbers

If you wish to make flowcharts simply, you should utilize Microsoft Visio 2003, as a result of I often use that model, however if you wish to use one other model, it is higher.

If you wish to obtain Microsoft Visio 2003, you’ll be able to click on the hyperlink right here.

Subsequent, we are going to enter this system creation stage ranging from PHP, Python, C++ and Java.

Program Determines Odd or Even Numbers

After the examples of algorithms and flowcharts for figuring out odd-even numbers have been mentioned, we are going to then transfer on to the tutorial on easy methods to implement them in a program, whether or not in a PHP, Python, C++ or Java program.

Instance Program for Figuring out Odd-Even Numbers Utilizing PHP

From the algorithm and flowchart that we made above about easy methods to decide odd and even numbers, now we implement it right into a program utilizing native PHP.




Figuring out Odd-Even Numbers

Enter the quantity:


Save the code above with the identify index.php into the xampp/htdocs/name_folder folder then check it in your browser.

Instance Program for Figuring out Even Odd Numbers Utilizing Python

From the algorithm and flowchart that we created above about easy methods to decide odd and even numbers, we now implement it right into a program utilizing Python.

print(“Enter quantity : “) invoice = int(enter()) if invoice % 2 == 0: print(str(invoice) + ” is a good quantity”) else: print(str(invoice) + ” is a good quantity odd numbers “)

Copy and paste the code above, then run it within the code editor that you just often use.

Instance Program for Figuring out Odd-Even Numbers Utilizing C++

From the algorithm and flowchart that we made above about easy methods to decide odd and even numbers, we now implement it right into a program utilizing C++.

#together with

utilizing namespace std; int predominant() { int quantity; cout< "Masukkan bilangan : "; cin >> invoice; if (quantity % 2 == 0) { cout << quantity << " is a good quantity" << endl; } else { cout << quantity << " is an odd quantity" << endl; } return 0; }

You copy and paste the code above, then run it with the C++ editor that you just often use.

Instance Program for Figuring out Odd-Even Numbers Utilizing Java

From the algorithm and flowchart that we’ve got made above about easy methods to decide odd and even numbers, now we implement it right into a program utilizing Java.

import java.util.*; public class OddEvenNumbers { public static void predominant(String[] args) { int quantity; Scanner enter = new Scanner(System.in); System.out.print(“Enter quantity: “); num = enter.nextInt(); if (quantity % 2 == 0) { System.out.println(Integer.toString(quantity) + ” is a good quantity”); } else { System.out.println(Integer.toString(quantity) + ” is an odd quantity); } } }

That is my rationalization about algorithms, flowcharts and applications for figuring out odd-even numbers utilizing the PHP, Python, C++ and Java programming languages. When you have any questions, please write them within the feedback column.

CATEGORIES
TAGS
Share This

COMMENTS

Wordpress (0)
Disqus ( )