Prototype: int toupper(int aChar);
Header File: ctype.h and stdlib.h
Explanation: toupper accepts a character as an argument (it actually accepts an integer, but the two are interchangeable) and will convert it to uppercase, and will return the uppercase character, in the form of an ASCII integer, and leave the parameter unchanged.
//Program creates char d, sets it equal to lowercase letter
//Converts it to uppercase and outputs it
#include <ctype.h>
#include <iostream.h>

int main()
  char d;
  return 0;

1) From the above function, int toupper(int aChar). My understanding is it takes only int value only
but from the explaination, it can take char and integer value. Would somebody pls explain!
When I key in "a" , it will output" A". Howver when I key in integer value which is equavalent to small
alphabet a , 97 or hex value 61. This programs output shows  9 for integer value and 6 for hex value.
Why it didnt appear capital "A"
Who is Participating?
nietodConnect With a Mentor Commented:
Computers use numbers to represent characters.  The ASCII code is a code that tells what number cooresponds to what letter, like 0 is 'a', 1 is 'b', 2 is 'c', etc.  (The real ASCII code uses different numbers.)

The data type "char" is simply a numeric type.  it is usually an 8 bit type.  That is, it holds values from 0 to 255 or perhaps from -128 to +127.

Since int is also a numeric type if can be used to store characters just as well as char.  The only difference is that it has a larger range of values, so some values of an int doesn't have a meaning as a character.

Why pass an int instead of a char?  Well on some computers it is faster and easier to pass int instead of character, because of the way the CPU works.

char d;


int d;

You are not putting the value 97 in the char d but the '9'. There is no upper case for '9'. When you replace the char with int you are putting the value of a char 'a' which is 97 in the variable d and this will convert to 'A'
Barath122599Author Commented:
Thank you very much

Since 97 is an acceptible number for char type variable.
So,why char d only receive 9 ? not 97?

I don't understand.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.