Create a function to write centered on screen the text that is indicated as a parameter (supposing a screen width of 80 characters): WriteCentered("Hello!");
Solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercisefunc5
{
class Program
{
public static void cener(string text)
{
int i =0;
for (;i<17;i++)
Console.WriteLine();
for(i = 0;i<36;i++)
Console.Write(" ");
Console.Write(text);
for (i = 0; i < 14; i++)
Console.WriteLine();
}
static void Main(string[] args)
{
cener("Hello");
Console.ReadLine();
}
}
}
Output: