Program to convert String to Uppercase C++

Write a Program to convert string to Uppercase C++.

PROGRAM:

#include<iostream>
using namespace std;

int main( )
{

    char str[80];
    cout<<"Enter a string:";
    gets(str);

    for(int i=0;str[i]!='';i++)
        str[i] = (str[i]>='a' && str[i]<='z')?(str[i]-32):str[i];
    cout<<str;

    return 0;
}

 

OUTPUT:

convert string to uppercase c++

Leave a Reply