Saturday 12 March, 2011

Write a function that will scan a character string passed as an argument and convert all lower-case character into their upper-case equivalent

#include<stdio.h>
#include<conio.h>
void upper(char[]);
int main()
{
char str[20];
clrscr();
printf("Enter string : ");
gets(str);
upper(str);
getch();
return 0;
}
void upper(char str[20])
{
int i;
printf("%s in upper case is ",str);
for(i=0;str[i];i++)
{
if(str[i]>96 && str[i]<123)
str[i]-=32;
}
printf("%s",str);
}
Output:
Enter string :string
string in upper case is STRING

No comments:

Post a Comment