title: C++ function to check if char is a capital letter and compute no of capital letters in a given string
body: <p>I tried to write a C++ function to check if a char is a capital letter in a given string.</p>
  
  <p>Here's my attempt:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include&lt;string&gt;
  using namespace std;
  int iscapital(char x)
  {
   if (x&gt;='A'&amp;&amp;x&lt;='Z')    return 1;
  
   else  return 0;
  }
  main()
  {
  char a[20];int len; int c=0;
  cout&lt;&lt;"enter your line: ";
  cin&gt;&gt;a;
  len=strlen(a);
  for (int i=0;i&lt;=len;i++)
  iscapital(a[i]);
  if (iscapital)
  {
      c++;
  }
  
  cout&lt;&lt;"capital letter in string is: "&lt;&lt;c;
  }
  </code></pre>