Skip to content

Instantly share code, notes, and snippets.

@portal7
Created January 27, 2021 03:14
Show Gist options
  • Save portal7/c85f56a207ee0f94e03549d59552ce39 to your computer and use it in GitHub Desktop.
Save portal7/c85f56a207ee0f94e03549d59552ce39 to your computer and use it in GitHub Desktop.
First Character of a sentence
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
String name = "University of Warwick";
printInitials(name);
}
static void printInitials(String name)
{
if (name.Length == 0)
return;
// Since touuper() returns int,
// we do typecasting
Console.Write(Char.ToUpper(name[0]));
// Traverse rest of the string and
// print the characters after spaces.
for (int i = 1; i < name.Length - 1; i++)
if (name[i] == ' ')
Console.Write(" " + Char.ToUpper(name[i + 1]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment