What to do if I require more input, output pins?

I am on a project, where i am required to interface more than 50 sensors and manipulate 50 motors, will I be able to do with arduino, I have purchased two arduino mega 2560, and I am perplexed about how to interface two boards?, Or else is there any other way where i could do this?

You can expand the digital input and output capabilities using i2c or spi i/o expanders like MCP23S17.
Analog io's can be expanded using i2c or spi ADC and DAC

Shift registers are another option for digital I/O. Units like the 74HC595 parallel out/serial in for output expansion and the 74HC165 serial out/parallel in for input expansion.

For output expansion (and output only), you can use the cheap 595 shift registers. I recently wrote a beginner's guide for these in my blog:
http://www.idogendel.com/en/archives/211

Siddique:
I am on a project, where i am required to interface more than 50 sensors and manipulate 50 motors, will I be able to do with arduino, I have purchased two arduino mega 2560, and I am perplexed about how to interface two boards?, Or else is there any other way where i could do this?

It would help quite a bit if you were to mention what kind of "sensors" you are using and how they interface. The answer for analog sensors will be MUCH different than for on/off sensors.
It would help quite a bit if you said HOW you want to 'manipulate' 50 motors. Do you want to just turn them on and off? Control their speed? Control speed and direction?!? Each degree of control requires different hardware.

Thanks to all,

It would help quite a bit if you were to mention what kind of "sensors" you are using and how they interface. The answer for analog sensors will be MUCH different than for on/off sensors.
It would help quite a bit if you said HOW you want to 'manipulate' 50 motors. Do you want to just turn them on and off? Control their speed? Control speed and direction?!? Each degree of control requires different hardware.

I am going to interface simple ir sensors with digital output, and accordingly on and off a motor using some motor drivers,