Friday, March 4, 2011

User-Defined Functions

Write a function that will scan a character string passed as an argument and convert all lowercase characters into their uppercase equivalents.

#include <stdio.h>
#include <ctype.h>
void UPPERCASE(char str[20]);
void main()
{
char str[20];
clrscr();
printf("Enter a string\n");
scanf("%s",str);
UPPERCASE(str);
getch();
}
void UPPERCASE(char str[20])
{
int i=0;
while(str[i]!='\0')
{
str[i]=toupper(str[i]);
i++;
}
printf("%s",str);
}

OUTPUT
Enter a string
Programming
PROGRAMMING

No comments:

Post a Comment