-->

WAP to convert given string into uppercase without using strupr() function.

in turboc++
----------------------------------------------------------------------------------
//program to convert given string into uppercase without strupr()
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
int main()
{
    char string[100];
    int i;
    printf("enter a string in lowercase\n");
    gets(string);//INPUT
    for(i=0;string[i]!='\0';i++)//LOOP EXECUTION
    {
        if(string[i]!=' ')//CONDITION TESTING
        printf("%c",string[i]-32);//CONVERTING INTO UPPERCASE BY subtracting 32
        else
            printf(" ");//PRINTING SPACE
    }
   getch();
    return 0;
}
------------------------------------------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------------------------
//program to convert given string into uppercase without strupr()
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char string[100];
    int i;
    printf("enter a string in lowercase\n");
    gets(string);//INPUT
    for(i=0;string[i]!='\0';i++)//LOOP EXECUTION
    {
        if(string[i]!=' ')//CONDITION TESTING
        printf("%c",string[i]-32);//CONVERTING INTO UPPERCASE BY subtracting 32
        else
            printf(" ");//PRINTING SPACE
    }
    return 0;
}

No comments:

Post a Comment