Your Tamagotchi can live forever, if you continously take good care of it. I've raised one for 34 generations before I accidently killed it. After 99 generations, it won't die, it will continue, just the counter stops going up.
Note: when the battery gets low, put in a new battery and select "Download" to continue with your old Tamagotchi character.