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
Just one note: to control 30 servos you will draw a fairly good amount of current, do not put all servos on arduino +5 voltage line.
If each servo draw 0.25 Amperes, 30 together will need 7.5 Amperes, way more than most of "wall mart" power supply can handle. Servos can draw easily more than .25 Amperes, depending on the load, type, etc...
I would opt to use 2 breakout boards from Adafruit if I were you, each board can be powered separately, they have example code on how to control the servo, and a very nice wiring diagram. So even not knowing anything regarding PWM and I2C you will get it working.
But, honestly, get it working and study what you are doing at the same time. 
Read this: https://learn.adafruit.com/16-channel-pwm-servo-driver
Vitor Henrique
Just one note: to control 30 servos you will draw a fairly good amount of current, do not put all servos on arduino +5 voltage line.
If each servo draw 0.25 Amperes, 30 together will need 7.5 Amperes, way more than most of "wall mart" power supply can handle. Servos can draw easily more than .25 Amperes, depending on the load, type, etc...
I would opt to use 2 breakout boards from Adafruit if I were you, each board can be powered separately, they have example code on how to control the servo, and a very nice wiring diagram. So even not knowing anything regarding PWM and I2C you will get it working.
But, honestly, get it working and study what you are doing at the same time. 
Read this: https://learn.adafruit.com/16-channel-pwm-servo-driver
Vitor Henrique