Pages

Get a string from user and convert it into upper case

Friday 19 April 2013

#include <stdio.h>

#include <conio.h>
char* upper(char *word);
int main()
{
    char word[100];
    printf("Enter a string: ");
    gets(word);
    printf("\nThe uppercase equivalent is: %s\n",upper(word));
    getch();
}

char* upper(char *word)
{
    int i;
    for (i=0;i<strlen(word);i++) word[i]=(word[i]>96&&word[i]<123)?word[i]-32:word[i];
    return word;

}
 

Search Box

Most Reading

Contact Form

Name

Email *

Message *