Program to input a string and print it.

Here, we have a basic program example to input a string and display it using different languages. This program is created in c language, c++, Java, and Python.

Code to input and print a string in C language

#include <stdio.h>
#include <stdlib.h>

void main()
{
    char str[50];
    printf("Input the string : ");
    scanf("%s", str);
    printf("The string you entered is : %s\n", str);
}

Code to input and print a string in C++ language

#include<iostream>
using namespace std;
int main()
{
    char str[20];
    cout<<"Input the string : ";
    cin>>str;
    cout<<"The string you entered is: "<<str;
    cout<<endl;
    return 0;
}

Code to input and print a string in Pythonn language

str=input("Enter a String: ")
print("The string you entered is: ", str)

Code to input and print a string in Java language

import java.util.*;
class stringQuestion1
{
  public static void main(String[] args)
   {
     Scanner sc= new Scanner(System.in);
     System.out.print("Enter a string: ");
     String str = sc.nextLine();
     System.out.println("The string you entered is: " +str);
   }
}