Posts

Showing posts from January, 2018

Write C# code to display the asterisk pattern as shown below:
*****
*****
*****
*****
*****

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace asteriskpattern {     class Program     {         static void Main(string[] args)         {             int n = 5, i, j;             for (i = 1; i <= n; i++)             {                 for (j = 1; j <= n; j++)                 {                     Console.Write("*");                 }                 Console.Write("\n");             }             Console.ReadKey();         }     } } Output: ***** ***** ***** ***** *****

C# code to prompt a user to input his/her name and country name and then the output will be shown as like: Hello Ram from country India!

Image
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace writenameandcountry {     class Program     {         static void Main(string[] args)         {             Console.WriteLine("Enter your name:");             string name = Console.ReadLine();             Console.WriteLine("Enter your country name:");             string country = Console.ReadLine();             Console.WriteLine("Hello {0} from country {1}!", name, country);             Console.ReadKey();         }     } } Output: Enter your name: Ram Enter your country name: India Hello Ram from country India!