Write a program to convert a string in uppercase.


Write a program to convert a string in uppercase.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
 
int main( )
{
        clrscr( );
        char str[80];
        cout<<"Enter a string:";
        gets(str);
 
        for(int i=0;str[i]!='\0';i++)
               str[i] = (str[i]>='a' && str[i]<='z')?(str[i]-32):str[i];
 
        cout<<str;
 
        getch();
        return 0;
}


No comments:

Post a Comment