C program to convert lower-case letters to upper-case


/* 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"

void upper(char str1[]);

void main()
{

char str[50], i;
printf("Enter a string: ");
scanf("%[^\n]", str);
upper(str);
printf("\n");
}

void upper(char str1[])
{
int i;
for(i=0; str1[i] != '\0'; i++)
{
str1[i] = toupper(str1[i]);
}
printf("%s", str1);
}

Output:





Comments

Popular Posts