Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Arrays and Strings
  5. Strings
  6. String Upper

String Upper

strupr()

Converts uppercase string to lowercase

strupr(string_name);

Program: convert string to uppercase using string function

#include<stdio.h>
#include<string.h>
int main() 
{
    char s[100];
    puts("Ener string in lowercase");
    gets(s);
    strupr(s);
    puts("After converting to uppercase,");
    puts(s);
    return 0;
}

Output

Ener string in lowercase
hello
After converting to uppercase,
HELLO

Program: Convert lowercase to uppercase without using library function

#include<stdio.h>
#include<string.h>
int main()
{
    char s[100];
    int i=0;
    puts("Enter string in lowercase");
    gets(s);
    while(s[i] != '\0')
    {
        if(s[i] >=97 && s[i]<=122)
        {
            s[i] = s[i] -32;
        }
        i++;
    }
    puts("After converting to uppercase");
    puts(s);
    return 0;
}

Output

Enter string in lowercase
itechbitz
After converting to uppercase
ITECHBITZ

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments