Use the functions char toUpper(char) to check if a char is a lowercase alphabetic value. If it is, return the uppercase equivalent. If it isn’t, return the original char.
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
char toUpper(char n){
if(islower(n)){
return toupper(n);
}
else{
return n;
}
}
int main(){
cout<<"Enter a character:\n";
char n;
cin>>n;
cout<<toUpper(n)<<endl;
}
Comments
Leave a comment