Ask a Teacher



What is wrong with the usages of the following functions? a) tolower ("hello") b) pow (5, 2.5)

As indicated by Banfa you need to include the appropriate header but also the function tolower() takes a single character (Iint) as a parameter and returns the corresponding lowercase letter (int), i.e.


#include<iostream>
#include<cctype>        // for tolower()
using namespace std;
 
int main() {
    char upper[]="HELLO", lower[10]={0};
    int i;
    for(i=0; i<strlen(upper); i++)
       lower[i] = tolower(upper[i]);  // convert each character
    cout<< lower << endl;
    cin.get();
}
 


comments powered by Disqus