Write a program to check if Person is Eligible for Driving Licence or Not in C
Write a program to check if Person is Eligible for Driving Licence or Not in C++
Write a program to check if Person is Eligible for Driving Licence or Not in Python
Write a program to check if Person is Eligible for Driving Licence or Not in PHP
Write a program to check if Person is Eligible for Driving Licence or Not in Java
Write a program to check if Person is Eligible for Driving Licence or Not in Java Script
Write a program to check if Person is Eligible for Driving Licence or Not in C#
Explanation:
Logic
If the person’s age is greater than or equal to the legal age (e.g., 18), they are eligible to apply.
If the person’s age is less than the legal age, they are not eligible.
Program to Scan Age of Candidate and Print if He/She is Eligible for Driving Licence or Not
C
C++
Python
PHP
JAVA
Java Script
C#
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
if (age >= 18) {
printf("You are eligible for a driving license.\n");
} else {
printf("You are not eligible for a driving license.\n");
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
int age;
cout << "Enter your age: ";
cin >> age;
if (age >= 18) {
cout << "You are eligible for a driving license." << endl;
} else {
cout << "You are not eligible for a driving license." << endl;
}
return 0;
}
age = int(input("Enter your age: "))
if age >= 18:
print("You are eligible for a driving license.")
else:
print("You are not eligible for a driving license.")
<?php
$age = readline("Enter your age: ");
if ($age >= 18) {
echo "You are eligible for a driving license.\n";
} else {
echo "You are not eligible for a driving license.\n";
}
?>
import java.util.Scanner;
public class DrivingLicenseEligibility {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = scanner.nextInt();
if (age >= 18) {
System.out.println("You are eligible for a driving license.");
} else {
System.out.println("You are not eligible for a driving license.");
}
scanner.close();
}
}
let age = prompt("Enter your age:");
if (age >= 18) {
console.log("You are eligible for a driving license.");
} else {
console.log("You are not eligible for a driving license.");
}
using System;
class Program {
static void Main() {
Console.Write("Enter your age: ");
int age = Convert.ToInt32(Console.ReadLine());
if (age >= 18) {
Console.WriteLine("You are eligible for a driving license.");
} else {
Console.WriteLine("You are not eligible for a driving license.");
}
}
}