The Federal Trade Commission recently issued its National Do Not Call Registry Data Book for 2017.  Since its start in 2003, the National Do Not Call list has grown to include 229 million phone numbers.  Registering for the Do Not Call list makes it illegal for telemarketers to contact you by phone.  The Do Not Call list does not apply to charities so you still may be contacted by charities even if you have registered for the Do Not Call list. However, when you receive a call from someone purporting to be representing a charity, you can never be sure who is really calling so you should never give your credit card number to someone who calls you allegedly from a charity. If you are interested in a particular charity, contact the charity directly to make your contribution.
It is also important to note that while telemarketing is not in and of itself illegal, telemarketing through robocalls is illegal.   Registering for the Do Not Call list will not stop robocalls. Illegal automated robocalls continue to be a major source of complaint for many people with the most common subjects of illegal robocalls being debt reduction, vacation and timeshares and warranty plans.
Registering for the do not call list is easy and free.  Merely go to to register your phone number.
There are a number of options for preventing robocalls including a number of apps that for free or a small fee will prevent robocalls. Here is a link to those for Android phones.
Here is a link to apps to prevent robocalls for iPhones.
For landlines, Nomorobo offers its robocall blocking for free.  Here is a link to Nomorobo. I have used Nomorobo for years and find it to be tremendously useful
Finally, you can just choose to ignore any calls that come from numbers you do not recognize.  If they are legitimate calls, they will leave a message and you can call them back.