C program to convert string to lowercase

list of programs below :  c program to convert string to lowercase using strlwr function, c program to convert string to lowercase without strlwr function, c program to convert string to lowercase using arrays, c program to convert string to lowercase using pointers.

strlwr function in c language is used to convert string to lowercase. strlwr function is defined under library string.h, so string.h file must be included before the program. The function strlwr takes string parameter and returns same string in lowercase.if the input string is in lowercase then the output will in lowercase as it is.
syntax: strlwr ( string str)

Note:  strlwr() does not work with all compilers. Use Turbo c  compiler for below programs

c program to convert string to lowercase using strlwr function
c program to convert string to lowercase using strlwr function

write a c program to convert string to lowercase using strlwr function

#include<stdio.h>
#include<string.h>
void main()
{
char str[30];
printf(“To convert a string to lowercase using strlwr \n “);
printf(“Enter a string to convert\n”);
gets(str);
printf(“\n lowercase of entered string is %s\n”, strlwr(str));
getch();
}

OUTPUT (RUN 1) :
To convert a string to lowercase using strlwr
Enter a string to convert
ABCDEFG
lowercase of entered string is abcdefg

write a c program to convert strings in array to lowercase using strlwr function

#include<stdio.h>
#include<string.h>
void main()
{
int i;
char str[5][30];
//str[no of strings][max string length]
printf(“To convert a strings in array to lowercase using strlwr \n “);
for(i=0;i<5;i++)
{
printf(“Enter the string \n”);
gets(str);
}
for(i=0;i<5;i++)
printf(“\n lowercase of  string %s is:\n %s\n”, str, strlwr(str));
getch();
}

OUTPUT :
To convert a strings in array to lowercase using strlwr

Enter the string
PROGRAMMINGSIMPLYSOLVED

Enter the string
Hello

Enter the string
hai

Enter the string
C Programming

Enter the string
THANKS

lowercase of  string PROGRAMMINGSIMPLYSOLVED is : programmingsimplysolved

lowercase of  string Hello is :
hello

lowercase of  string hai is :
hai

lowercase of  string C Programming is :
c programming

lowercase of  string THANKS is :
thanks

Program Logic for c program convert string to lowercase without strlwr function:

Each character is represented as an ascii value, to convert string to lowercase, check for uppercase characters in string i.e values >64 and <92 and Each lowercase character has ascii value +32 to that of same character in uppercase. so adding +32 to uppercase characters convert s to lowercase

C Program to convert string to lowercase using arrays pointers
C Program to convert string to lowercase using arrays pointers

write a C Program to convert string to lowercase using arrays

write a C Program to convert string to lowercase using arrays

#include <stdio.h>
#include <conio.h>
void main()
{
char ch[30];
char ch2[30];
printf(“enter string \n”);
scanf(“%c”, &ch)
ch2=lowercase(ch);
printf(“%c is lowercase of %c, ch2, ch);
getch();
}

char[] lowercase(char s[30])
{
int i=0;
while (s[i]!=’\0′)
{
if(s[i]>64 && s[i]<92
s[i]=s[i]+32;
i++;
}
return (s[30]);
}

OUTPUT:

enter string
HELLO
hello is lowercase of HELLO

write a C program to convert string to lowercase using arrays

write a C program for converting string to lowercase using arrays & for loop

#include <stdio.h>
#include <conio.h>
void main()
{
char ch[30];
char ch2[30];
printf(“enter string to convert\n”);
scanf(“%c”, &ch)
ch2=lowercase(ch);
printf(“%c is lowercase of %c, ch2, ch);
getch();
}

char[] lowercase(char s[30])
{
for( i=0; s[i] !=’\0′;i++)
{
if(s[i]>64 && s[i]<92
s[i]=s[i]+32;
}
return (s[30]);
}

OUTPUT:

enter string to convert

HELLO

ihello is lowercase of HELLO

write a C program to convert string to lowercase using pointers

write a C program to convert string to lowercase using pointers / write a C program to convert string to lowercase without strlwr

#include<stdio.h>
#include<conio.h>
void main()
{
char ch[25];
printf(“enter string to convert\n”);
gets(ch);
string str=lowercase(ch);
printf(“\n The Lowercase string is %s”,str);
}
string lowercase(char *str)
{
while(*str!=’\0′)
{
if(*str<91&&*str>64)
*str=*str+32;
str++;
}
return str;
}

OUTPUT

Enter a string to convert
HAI
The Lowercase string is hai

 

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
convert decimal number to octal
decimal number to hexadecimal
decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

Leave a Reply

Your email address will not be published. Required fields are marked *