Pages

Saturday, 20 June 2015

User defined string function to convert to lower case to upper case

User defined string function to convert a given string lower case to upper case

Coding:
#include<stdio.h>
void mystrupr(char *a)
{
int i;
for(i=0;a[i]!='\0';i++)
{
if(a[i]>=97 && a[i]<=122)
a[i]=a[i]-32;
}
}
int main()
{
char a[30];
printf("Please enter the string:");
gets(a);
mystrupr(a);
printf("String in Upper Case:%s",a);
return 0;
}

Output:
Please enter the string:ProGraM
String in Upper Case:PROGRAM