Write a program to Convert character to string
Example 1:
Input: ch='a'
Output: str="a"
Approach:
Java
public class CharacterToString {public static void main(String[] args) {// input characterchar ch = 'a';// convert the character to stringString str = String.valueOf(ch);System.out.println("String is " + str);}}
C++
#include <bits/stdc++.h>using namespace std;int main(){//input characterchar ch='a';//convert the character to stringstring str(1,ch);//print the stringcout<<str<<"\n";return 0;}
No comments:
Post a Comment