Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
c# string abbreviation
/* * C# Program to Display the Abbreviation of a Text */ using System; using System.Collections.Generic; using System.Linq; using System.Text; class abbreviation { string str; public void readdata() { Console.WriteLine("Enter a String :"); str=Console.In.ReadLine(); } public void abbre() { char[] c, result; int j = 0; c = new char[str.Length]; result = new char[str.Length]; c = str.ToCharArray(); result[j++] = (char)((int)c[0] ^ 32); result[j++] = '.'; for (int i = 0; i < str.Length - 1; i++) { if (c[i] == ' ' || c[i] == '\t' || c[i] == '\n') { int k = (int)c[i + 1] ^ 32; result[j++] = (char)k; result[j++] = '.'; } } Console.Write("The Abbreviation for {0} is ", str); Console.WriteLine(result); Console.ReadLine(); class initials { 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])); } } public static void Main() { abbreviation obj=new abbreviation(); obj.readdata(); obj.abbre(); { String name = "prabhat kumar singh"; printInitials(name); } } }
run
|
edit
|
history
|
help
0
Simplified palindrome test using stack
Non-User input - Random Controlled - Guessing Game
orytitoyt
Problem: rstring
Dotnetq5
MegaWays3
Main
Chris Kasongo Lazarius Mukengeshayi "Entelect BlackJack 21"
asxsd
Random number string changer