how to install virtualbox in ubuntu

C++
wget –q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
#use codename of your linux version,for my case focal is codename for 
#ubuntu 20.04.1
sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian focal contrib"
#you can check codename of your system using command below
lsb_release -cs
sudo apt update && sudo apt install virtualbox-6.1How to install Ubuntu 16.04 in VMware Workstation

Step 01: Create a New Virtual Machine
Step 02: Select Hardware Compatibility
Step 03: Use or select Ubuntu 16.04 Image to install
Step 04: Configure Virtual Machine Name and file Location
Step 05: Configure Virtual processor for new virtual machine
Step 06: Setup Virtual RAM memory for new virtual machine
Step 07: Setup Virtual Machine Network 
Step 08: Configure Virtual storage disk for new virtual machine
Step 09: Now power on of the virtual machine after finish the VMware setup
Step 10: Get the Ubuntu setup screen on display

follow the given instruction on screen and it will install in 10 min.

Source

Also in C++: