How to write a C Program to convert a string to upper case in C Programming Language ?
This C Program to convert a string to upper case.
Solution:
- #include<stdio.h>
- #include<string.h>
- main()
- {
- char s[50];
- int i,l;
- printf("Enter some text: ");
- gets(s);
- l=strlen(s);
- for(i=0;i<l;i++)
- {
- if(s[i]>='a'&&s[i]<='z')
- s[i]-=32;
- }
- printf("Text after converting to upper case: ");
- puts(s);
- }