There is no way of UPGRADING a MySQL install from 4.0 to 5.5 directly.
This has multiple reasons: 4.1 introduced a new password encryption and invalidates all the user credentials stored in a 4.0 install.
5.0 introduced an incompatible change in the storage engine MyISAM which will invalidate all the stored data from a 4.1 and older database.
The only way to upgrade the existing install is to do the upgrade from 4.0 to 4.1 and then to 5.0 and then to 5.1 and then to 5.5 (You may skip 5.2 to 5.4)
After installing the newer version on top, you need to run the mysql_upgrade tool which should in most cases do all the structural upgrades for you.
You can of course dump your databases and recreate the contents in 5.5 or 5.6. I'd say this is the preferred way to do things.
Run MySQLDump to create a file containing the SQL statements for creating all databases and the contained data:
mysqldump -uroot -p --all-databases > backupfile.sql
And then restore that data in the new MySQL 5.5 system:
mysql -uroot -p < backupfile.sql
You might need to change the passwords (if any) for the MySQL users as the password encryption changed from MySQL 4.0 to 4.1
Documentation for the in-place upgrade of MySQL 4.0 to 5.5 can be found in these locations:4.0 => 4.14.1 => 5.05.0 => 5.15.1 => 5.5