Link to home
Start Free TrialLog in
Avatar of Barath122599
Barath122599

asked on

ASCII

toupper()
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.
Example:
//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;
  cin>>d;  
  d=toupper(d);
  cout<<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"
Avatar of wytze
wytze

replace

char d;

with

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'
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Barath122599

ASKER

Thank you very much
Sorry.

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

Thanks
I don't understand.