Cranes at VIIT Q25

Structures with Multiple Fields - Vehicle Fleet

Problem Statement:

Write a C program using a struct named Vehicle that stores the following information for each vehicle in a fleet:

The program should:

  1. Initialize data for 5 vehicles (hardcoded).
  2. Display all vehicle details.
  3. Calculate and print the maximum distance each vehicle can travel with its current fuel (currentFuel × mileage).
  4. Identify and print the vehicle that can travel the farthest and display its full details.

Vehicle Data (Hardcoded):

Registration No Owner Name Type Mileage Fuel Cap Current Fuel
AP09AB1234 Ramesh Kumar Car 18.5 45 30
TS10CD5678 Sneha Reddy Truck 6.0 120 80
AP29XY7890 Aamir Hussain Van 12.0 60 40
TS07MN3456 Divya Sharma Car 16.0 50 25
AP31PQ1122 Arjun Patel Truck 5.5 130 100

Expected Output:

Fleet Vehicle Details:
======================================
Registration Number:    AP09AB1234
Owner Name:             Ramesh Kumar
Vehicle Type:           Car
Mileage (km/l):         18.50
Fuel Capacity (l):      45.00
Current Fuel (l):       30.00
Maximum Distance:       555.00 km
--------------------------------------
Registration Number:    TS10CD5678
Owner Name:             Sneha Reddy
Vehicle Type:           Truck
Mileage (km/l):         6.00
Fuel Capacity (l):      120.00
Current Fuel (l):       80.00
Maximum Distance:       480.00 km
--------------------------------------
Registration Number:    AP29XY7890
Owner Name:             Aamir Hussain
Vehicle Type:           Van
Mileage (km/l):         12.00
Fuel Capacity (l):      60.00
Current Fuel (l):       40.00
Maximum Distance:       480.00 km
--------------------------------------
Registration Number:    TS07MN3456
Owner Name:             Divya Sharma
Vehicle Type:           Car
Mileage (km/l):         16.00
Fuel Capacity (l):      50.00
Current Fuel (l):       25.00
Maximum Distance:       400.00 km
--------------------------------------
Registration Number:    AP31PQ1122
Owner Name:             Arjun Patel
Vehicle Type:           Truck
Mileage (km/l):         5.50
Fuel Capacity (l):      130.00
Current Fuel (l):       100.00
Maximum Distance:       550.00 km
--------------------------------------

Vehicle that can travel the farthest:
======================================
Registration Number:    AP09AB1234
Owner Name:             Ramesh Kumar
Vehicle Type:           Car
Mileage (km/l):         18.50
Fuel Capacity (l):      45.00
Current Fuel (l):       30.00
Maximum Distance:       555.00 km
--------------------------------------
            

Task: Implement the above logic using a structure in C and proper float formatting for output.