Sunday, 24 April 2022

4. Write a program, which takes a name of the user in the lowercase letters. Call a user defined function upper which will convert all lowercase letters into the uppercase letter. Finally print the string.



#include<stdio.h>
#include<conio.h>

void uppercase(char *);

void main()
{
    char str1[90],str2[90];
    clrscr();

    printf("enter string: ");
    gets(str1);

    printf("\n\nyour string in lowercase: %s",str1);

    uppercase(str1);

    getch();
}

void uppercase(char *str2)
{
    int i;

    for(i=0; str2[i] != '\0'; i++)
    {
        if(str2[i] != ' ')
        {
            str2[i] = str2[i] - 32;
        }
    }

    printf("\n\nyour string in uppercase: %s",str2);
}

/*  output:

enter string: vrushal pandav


your string in lowercase: vrushal pandav

your string in uppercase: VRUSHAL PANDAV

*/ 

No comments:

Post a Comment

python programs

1. sum of two number