I am trying to connect two routers in one switch to ping each other using IP route .
router 0 has 192.168.10.1/24 gi0/0
router 1 has 192.168.20.1/24 gi0/0
I tried putting switch-port trunks on both fa0/1 and fa0/2 for switch 0
For the two routers to communicate with each other they need to share a common network (across the switch in your diagram).
So, using e.g. 192.168.10.1/16
and 192.168.20.1/16
(or up to /18) would work, while 192.168.10.1/24
and 192.168.20.1/24
will not.
Both the routers has to share same network subnet to ensure communication between two router's ..
For example
1 ) 192.168.10.1/24 for first router 2) 192.168.10.2/24 for second router
Then both router will communicate..