Write a C function print_upper() to prints its character argument in uppercase.(Using function).

#include<stdio.h>
void print_upper(char *s)
{
     int i=0;
     while(s[i]!='\0')
     {
        if(s[i]>=97 && s[i]<=123)
           s[i]=s[i]-32;
        i++;
     }
}

main()
{
     char str[100];
     printf("\nEnter a string=");
     scanf("%s",str);
     printf("\nThe original string=%s",str);
     print_upper(str);
     printf("\nThe after conversion string=%s",str);
}

No comments:

Post a Comment