Here we are going to write a trigger for roll-up summary on account object to sum the total contacts associated with an account. Before that you have to create a custom field on account with the name "No_Of_Contacts__c" or you can make with your own and change this "No_Of_Contacts__c" in code with yours.