//WAP in C to convert a string from Lower case to Upper case
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
void main()
{
char string[50];
int count=0, ch, i;
clrscr(); // for clearing the console screen
printf("Enter a string\n");
gets(string); //input string
for(i=0;string[i]!='\0';i++)
{
count++; //count the number of characters in the string or use strlen()
}
printf("The entered string is : %s",string); //printing the entered string
printf("\nUpperCase string is: ");
// logic for converting the string in uppercase
for(i=0; i < count; i++)
{
ch = toupper(string[i]); //changing lower case character to upper case
printf("%c",ch);
}
getch(); // holding the console screen
} // End of main()
No comments:
Post a Comment