C# Cognizant Handson Solutions

StringConcatenate Handson Solution Cognizant

 Write a program which asks the user for their first name and last name to enter separately .

 Concatenate these strings, with a space in-between them, putting the resulting concatenation into a single string variable named fullName and output the concatenated string to the console.

SAMPLE INPUT / OUTPUT :Enter first name
Alice
Enter last name
Maria

Full name : Alice Maria

Program.cs

using System;

public class Program      //DO NOT change the class name
{
    //implement code here
    static void Main(string[] args)
    {
        string fname, lname, fullName;
        Console.WriteLine("Enter first name:");
        fname = Console.ReadLine();
        Console.WriteLine("Enter last name:");
        lname = Console.ReadLine();
        fullName = fname + " " + lname;
        Console.WriteLine("Full name : " + fullName);
    }
}

Similar Posts