In this tutorial we are writing a pseudocode to Check Eligibility for voting.
write a program to input your age check whether you are eligible for voting or not
To check that a person is eligible for voting or not, we need to check whether person’s age is greater than or equal to 18. For this we are reading age in a variable a and checking the condition a>=18, if the condition is true, “person will be eligible for voting” else not.
Program Source Code : pseudocode to check eligibility for voting
Pseudocode:
1 2 3 4 5 6 7 8 9 10 11 12 13 | BEGIN NUMBER age DISPLAY "Enter age" IF age >= 18 DISPLAY "Eligible for Voting! " ELSE DISPLAY "NOT Eligible for Voting! " END IF END |
Flowchart:
Python:
1 2 3 4 5 6 7 8 | age = int(input("Enter age : ")) if age >= 18: print("Eligible for Voting!") else: print("Not Eligible for Voting!") |
C++:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> using namespace std; int main() { int age; cout<<"\nEnter age"; cin>>age; if(age >= 18) cout<<"Eligible for Voting! "; else cout<<"Eligible for Voting! "; return 0; } |
C#:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | using System; class Program { public static void Main (string[] args) { Console.WriteLine("Enter age :"); int age = Convert.ToInt32(Console.ReadLine()); if (age >= 18) Console.WriteLine("Eligible for Voting!"); else Console.WriteLine("Not Eligible for Voting!"); } } |
Java:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Create a Scanner object System.out.print("Enter age :"); int age = sc.nextInt(); // Read user input if (age >= 18) System.out.print("Eligible for Voting!"); else System.out.print("Not Eligible for Voting!"); } } |
PHP:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <html> <head> <title>PHP Test</title> </head> <body> <form method="get"> <input name="age" placeholder="enter age"><br> <input name="btn" type="submit" value="Submit Age"> <?php if(isset($_GET["age"])) { //solution $age = $_GET["age"]; echo "<h2> Your Age:$age<h2>"; if ($age >= 18) echo "<h1>Eligible for Voting!</h1>"; else echo "<h1>Not Eligible for Voting!</h1>"; } ?> </form> </body> </html> |