Simple program problem from upper to lower case
My homework is to create a program that changes an Uppercase letter to a lower case letter. My teacher has not introduced the tolower function, so I am not using it. We were also required to use the cout.put and cin.get functions. Anyway, my program works but when I send it through my teachers automated assignment checker I get 2 warnings (this will cost me points). The warnings are as follows:
Source 1.cpp(39) : warning C4244: 'argument' : conversion from 'int' to 'char', possible loss of data
and
cout.put((int)myLower); // cout.put outputs char found by myUpper + TOLOWER
Source 1.cpp(39): error 734: (Info -- Loss of precision (arg. no. 1) (31 bits to 7 bits))
Here is my code. Thank you for help in advance:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int myUpper; // declares myUpper an integer allowing us to use const char TOLOWER
int myLower;
const int TOLOWER = ' '; // initializes TOLOWER to ' ' which has decimal value of 32
cout << "Please Enter an Upper Case Letter: "; // asks user for myUpper
myUpper = cin.get(); // cin.get takes first character entered by user
myLower = myUpper + TOLOWER; // add value of 32 to upper case decimal value to find a lower case
cout << "\nYour Lower Case Letter is: ";
cout.put((int)myLower); // cout.put outputs char found by myUpper + TOLOWER
cout << "\n\n"; // newlines entered for clarity
return(EXIT_SUCCESS);
}