PPS Practical 48

PPS Practical 48
  • Aim: Write a function that will scan a character string passed as an argument and convert all lowercase character into their uppercase equivalents
  • Code:
    //For turbo C++ remove below comments
    #include <stdio.h>
    //#include<conio.h>
    char* upper(char s[]){
        int i;
        for (i = 0; s[i]!='\0'; i++){
            if (s[i]>96 && s[i]<123){
                 s[i]-=32;
            }
        }
        return s;
    }
    void main()
    {
        //clrscr();
        char str[99];
        printf("Enter string : ");
        gets(str);
        printf("String in upper case : %s",upper(str));
        // getch();
    }
  • Output:
    Output of practical 48

Comments