Sunday, April 14, 2013

String: Write a c program to convert the string from lower case to upper case

Convert String from lowercase to uppercase 



#include<stdio.h>
#include<string.h>
int main()
{
  char str[50];
  int i,b=0;
  printf("Enter lowercase word: ");
  scanf("%s",str);
  b=strlen(str);
  for(i=0;i<=b;i++)
    {
        if(str[i]>=97&&str[i]<=122)
        str[i]=str[i]-32;
  }
  printf("\nThe string in Uppercase is:%s",str);
  return 0;
}

2 comments:

  1. //CONVERT STRING UPPERCASE TO LOWERCASE

    #include
    #include
    main()
    {
    char rose[50];
    int i,manoshe=0;
    printf("Enter the uppercase word: ");
    scanf("%s",rose);
    manoshe=strlen(rose);
    for(i=0;i<=manoshe;i++)
    {
    if(rose[i]>=65&&rose[i]<=90)
    rose[i]=rose[i]+32;
    }
    printf("\nThe string is lowercase is: %s\n",rose);
    return 0;
    }

    ReplyDelete