Computer Science, asked by afeenafathima, 2 days ago

Accept the name of a user and using it display "hello"​

Answers

Answered by simonsaikia9
0

Using C:

int main()

{

   char a[100];

   printf("Enter the name: ");

   gets(a);

   printf("Hello! %s", a);

   return 0;

}

Using C++:

#include <iostream>

using namespace std;

int main()

{

   string name;

   cout << "Enter the name: ";

   getline(cin, name);

   cout << "Hello! " << name;

}

Using Java:

import java.util.Scanner;

public class hello {

   public static void main(String[] args) {

       String name;

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter the name: ");

       name = sc.nextLine();

       System.out.println(name + " is saying Hello");

   }

}

Similar questions