I wanted to know how can I turn an analog input to output or a digital IO(without pwm)to pwm signals using arduino
If you can't understand how to use that library I would say to stop what you are trying to do for some days, buy a book online (those getting started with arduino should do), and study a little bit before putting your hands on.
You will only understand and actually have some (good) questions after you study. Your question was vague and giving you a written code will not help, you need to understand what is PWM and how it works. Then you need to ask yourself why you need PWM on your project, what are you trying to do? Arduino Mega has 15 PWM iIOS, do you really need more than that? if so, shouldn't you use a dedicated IC to control what ever you are trying to control?
There are several IC's do control leds / servos that handle the PWM internally, not depending on the microcontroller hardware pwm itself.
For example, using the PCA9685 you can control 16 pwm using I2C interface. You can chain up 62 IC's to control up to 992 PWM outputs.
Adafruit has a breakout board for that chip and a lot of useful information.
I second this comment. You seem to ask a whole ton vague but basic questions on many subjects. I think you'd fair well getting an Arduino book and reading through it.
Simon Monk's books get good reviews
Amazon.com: Programming Arduino Getting Started with Sketches (9780071784221): Simon Monk: Books
I am a bit on the intermediate side and I know regarding i2C. my goal is to control almost 30-25 servos and max pwm is by mega(15) and I had to use twice as much. I never learnt I2C but know the concept. Regarding books I have a arduino cookbook and takes a while to learn(637 pages).
For servos there definitely are software pwm options as that pwm isn't fast
For servos there definitely are software pwm options as that pwm isn't fast