title: How to calculate the CPU usage of a process by PID in Linux from C?
body: <p>I want to programmatically [in C] calculate CPU usage % for a given process ID in Linux.</p>
  
  <p>How can we get the realtime CPU usage % for a given process?</p>
  
  <p>To make it further clear:</p>
  
  <ul>
  <li>I should be able to determine the CPU usage for the provided processid or process.  </li>
  <li>The process need not be the child process.  </li>
  <li>I want the solution in 'C' language.</li>
  </ul>