Converting a lower case string into upper case string

Problem statement
Write a c program to convert a lower case string into upper case string
#include<stdio.h>
int main()
{
  char a[20];
  int i=0;
  printf("Enter the lower case string:");
  scanf("%s",&a);                            /* scanning a string */
  printf("The UPPER case String is: ");
  while(a[i]!='\0')
  {
    a[i]=a[i]-32;    /* as ansii code of upper case is 32 less then lower case */
    i++;
   }
   printf("%s",a);
   return 0;
}

No comments:

Post a Comment