Capitalizing Function

 #include <iostream>

using namespace std;

//If you know the difference between ASCII values of small and capital letters.

char convert1(char name)

{

    char ans=name-32;

    return ans;

}

//If you do  not know the difference between ASCII values of small and capital letters.

char convert(char name)

{

    char ans=name-'a'+'A';

    return ans;

}

int main()

{

    char name;

    cout<<"Give the letter:-\n";

    cin>>name;

    cout<<convert1(name)<<endl;

    cout<<convert(name);

}


Comments

Popular posts from this blog

Sum of two integers using functions

Prime Numbers and Factorial function