Can anyone please help in Reading the analog values from Arduino Mega2560

Can anyone please help in writing the code to Read analog values from Arduino Mega2560 and display the signal in digital oscilloscope. My project require Analog-In and Analog -Out and was asked to display the input signal at the output.
And I need some help in code and ideas regrading the implementation. Thank You so much.

I've never done that but I guess the most complicated thing is setting a known sample rate. I found something [u]here[/u].

Otherwise reading the ADC is fairly straightforward. The input does have to be between 0 and +5V. If you want to read an AC signal, you need to bias the input (typically at 2.5V) so you can read the negative half of the signal. You may also need to amplify or attenuate the signal.

What's the frequency? The Arduino isn't super-fast...

and display the signal in digital oscilloscope.

Do you have an oscilloscope, or are you trying to make an oscilloscope? If you are making a 'scope, of course you'll need an LCD display.

Building a good-usable 'scope is not easy. It generally needs a high sampe rate, variable sweep-rate, high input impedance, flat frequency response (and related good pulse response), variable gain/attenuation, over-voltage protection, variable trigger threshold, user-friendly controls, etc.

My project require Analog-In and Analog -Out

What's the analog out for? The Arduino doesn't have a DAC, but since you have analog-in you can pass the analog through to an output (optionally buffered and/or amplified).