c#,display,abbreviation,of,text

Ron 8/15/2016 0

This Code Shows How to Display the Abbreviation of a Text

C#
 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();
 
    }
        public static void Main()
        {
            abbreviation obj=new abbreviation();
            obj.readdata();
            obj.abbre();
        }
} 

/*
Here is the output of the C# Program: Enter a String : meenakshi sundarajan engineering college The Abbreviation for meenakshi sundarajan engineering college is M.S.E.C.

*/

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments