Table of Contents
示例
输出
Home Backend Development C++ Write a C program to convert uppercase letters to lowercase letters without using string conversion functions

Write a C program to convert uppercase letters to lowercase letters without using string conversion functions

Aug 29, 2023 pm 02:45 PM
c program Case conversion character processing

Write a C program to convert uppercase letters to lowercase letters without using string conversion functions

在了解如何在不使用字符串转换函数的情况下将大写字母转换为小写字母之前,让我们来看一下使用转换函数将大写字母转换为小写字母的程序,然后您将清楚我们在程序中所做的事情:

示例

1

2

3

4

5

6

7

8

9

10

#include <stdio.h>

#include <string.h>

int main(){

   char string[50];

   printf("enter a string to convert to lower case</p><p>");

   gets(string); /reading the string

   printf("The string in lower case: %s</p><p>", strlwr(string)); //strlwr converts all upper    to

   lower

   return 0;

}

Copy after login

输出

1

2

3

enter a string to convert to lower case

CProgramming LangUage

The string in lower case: cprogramming language

Copy after login

现在让我们看看不使用预定义函数将大写转换为小写的程序 -

示例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

#include<stdio.h>

void main(){

   //Declaring variable for For loop (to read each position of alphabet) and string//

   int i;

   char string[40];

   //Reading string//

   printf("Enter the string : ");

   gets(string);

   //For loop to read each alphabet//

   for(i=0;string[i]!=&#39;\0&#39;;i++){

      if(string[i]>=65&&string[i]<=90){

         string[i]=string[i]+32;

      }

   }

   printf("The converted lower case string is : ");

   puts(string);

}

Copy after login

输出

1

2

Enter the string : TUTORIALSPOINT

The converted lower case string is : tutorialspoint

Copy after login

The above is the detailed content of Write a C program to convert uppercase letters to lowercase letters without using string conversion functions. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Translate the following into Chinese: C program to convert Roman numerals to decimal numbers Translate the following into Chinese: C program to convert Roman numerals to decimal numbers Sep 05, 2023 pm 09:53 PM

Translate the following into Chinese: C program to convert Roman numerals to decimal numbers

C++ program to compare the lexicographic order of two strings C++ program to compare the lexicographic order of two strings Sep 04, 2023 pm 05:13 PM

C++ program to compare the lexicographic order of two strings

C program to find length of linked list C program to find length of linked list Sep 07, 2023 pm 07:33 PM

C program to find length of linked list

C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument Sep 17, 2023 am 10:49 AM

C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument

C++ program to print dictionary C++ program to print dictionary Sep 11, 2023 am 10:33 AM

C++ program to print dictionary

C program uses rename() function to change file name C program uses rename() function to change file name Sep 21, 2023 pm 10:01 PM

C program uses rename() function to change file name

C program to implement Euclidean algorithm C program to implement Euclidean algorithm Sep 17, 2023 pm 12:41 PM

C program to implement Euclidean algorithm

C++ program to get the imaginary part of a given complex number C++ program to get the imaginary part of a given complex number Sep 06, 2023 pm 06:05 PM

C++ program to get the imaginary part of a given complex number

See all articles