大文字を小文字に変換し出力

Contents

出力結果

abc

プログラム例

C

#include <stdio.h>
#include <ctype.h>

int main () {
   int i = 0;
   char str[] = "ABC";
   while( str[i] ) {
      str[i] = tolower(str[i]);
      i++;
   }
   printf("%s\n", str);
   return(0);
}

C++

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

int main (int argc, char *argv[]) {
	std::string s("ABC");

	transform (s.begin (), s.end (), s.begin (), tolower);
	std::cout << s << std::endl;

	::exit (EXIT_SUCCESS);
}

Java

public class Lower {
    public static void main(String[] args) {
        String str = "ABC";
        System.out.println( str.toLowerCase() );
    }
}

JavaScript

let str = "ABC";
console.log(str.toLowerCase());

PHP

<?php
$str = "ABC";
print(strtolower($str)."\n");

Perl

my $str = "ABC";
print(lc($str)."\n");

Python

str = "ABC"
print(str.lower())

Ruby

str = "ABC"
print(str.downcase() + "\n")