The passwords are one of the main important fact in the sense of security . Passwords in Cisco routers are of two types encrypted passwords and decrypted passwords . Here i am going to say about , how to recover the router without deleting any router settings .
Step 1 :- Restart the router by pressing the power button on and off

System Bootstrap, Version 12.1(3r)T2, RELEASE SOFTWARE (fc1)
Copyright (c) 2000 by cisco Systems, Inc.
cisco 2811 (MPC860) processor (revision 0x200) with 60416K/5120K bytes of memory
Self decompressing the image :
#################################

Step 2 :- Before the self decompressing you should press Ctrl + break ( pause break ) .. a new option will be opened as shown below

System Bootstrap, Version 12.1(3r)T2, RELEASE SOFTWARE (fc1)
Copyright (c) 2000 by cisco Systems, Inc.
cisco 2811 (MPC860) processor (revision 0x200) with 60416K/5120K bytes of memory
Self decompressing the image :
######################
monitor: command “boot” aborted due to user interrupt
rommon 1 >

Step 3:- Now we are @ Rom mode as it shows rom prompt in the screen .

rommon 1 > confreg 0x2142
rommon 2 > reset
System Bootstrap, Version 12.1(3r)T2, RELEASE SOFTWARE (fc1)
Copyright (c) 2000 by cisco Systems, Inc.
cisco 2811 (MPC860) processor (revision 0x200) with 60416K/5120K bytes of memory
Self decompressing the image :
##############################

Step 4 :- The router will restart automatically once again and will ask Continue with configuration dialog? [yes/no]: no and press enter

Continue with configuration dialog? [yes/no]: no
Press RETURN to get started!
Router>

Step 5:- Enter into privilege mode and copy the start up configuration

Router>enable
Router#copy startup-config running-config
Destination filename [running-config]?
669 bytes copied in 0.416 secs (1608 bytes/sec)
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#enable secret ccna
Router(config)#line vty 0 4
Router(config-line)#login
Router(config-line)#password ccna
Router(config-line)#line con 0
Router(config-line)#password ccna

Step 6:- @ Present you haven’t saved the settings before restart make it all into default

Router(config)# config-register 0x2102
Router(config)# exit
Router# copy running-config startup-config
Destination filename [startup-config]?
Building configuration…
[OK]
Router# reload

The Router is back into function . Now its easy to recover a router if you forget the password to. Try it with cisco packet tracer first and then go with real time .