I am writing a function which will check if the letter is in upper case , if so it returns true otherwise false.
Following is the code, I have written, but what is wrong?

#include<iostream>


using namespace std;


using std::cout;
using std::cin;
using std::endl;


int isUpperCase ( char );


int main()


{
int i;
char c;


cout<<"Enter a charactor : ";
cin>>c;


i = int ( c );


isUpperCase ( i );



return 0;



}


int isUpperCase ( i )


{
if ( i > 65 && i < 90 )


return 1;


else


return 0;


}

please comment.

Why u are converting a char to int, you can compare char same as u compare int.

How about...

#include <iostream>
#include <string>

using namespace std;

class Foo
{
public:
   bool isUpperCase( char t )
   {
     string crap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     int size = crap.length();
     
      // check if the same return true 
     //otherwise return false

};


int main()
{ 
  Foo test;
  cout << test.isUpperCase('a') << endl;
  
  cout << test.isUpperCase('A');
  
  cin.get();
}

hi,
you can also mask bit on position# 6, which is 0 if char is upper case and 1 if char is lower case, e.g. 'A' = 0x41 = 0100 0001 (binary), 'a' = 0x61 = 0110 0001 (binary).

bool isUpperCase (char c) {return !(c&0x20);}
. . .
char c='z';
cout<<c<<(isUpperCase(c)?" is upper ":" is lower ")<<"char";
// z is lower char

krs,
tesu

I see nothing wrong with the function isUpperCase except from what mitrmkar sead, it would not work if you passed the function the characters 'A' or 'Z'.