answersLogoWhite

0

How do you write a c program to generate abbreviation using a string?

Updated: 8/20/2019
User Avatar

Susmitad

Lvl 1
12y ago

Best Answer

The algorithm to generate an abbreviation from a string may not be as dynamically sound as the algorithm utilized by the human mind, but it is possible. Here is a simple algorithm.

string word("dinosaur"), abbr("");

for each char in word

if char is consonant { add to abbr; }

endfor

This would transform "dinosaur" into "dnsr" and obviously that isn't what you would want.

You could count the characters, divide by two, take that integer result and gather that amount of characters followed by the last character as an abbreviation.

string word("dinosaur"), abbr("");

int length = word.length() / 2;

for (int i = 0; i < length; i++) {

if (i <= length)

abbr.push_back(word[i]);

}

abbr.push_back(word[length - 1]);

This would produce: "dinor" and that is definitely not a very useful abbreviation...

These algorithms are off the top of my head and I'm sure someone else could write better ones, but good luck with your endeavors.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a c program to generate abbreviation using a string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program to generate uppercase using cSharp?

string s = "asdfqwer"; s = s.ToUpper(System.Globalization.CultureInfo.CurrentCulture);


Write a program in java to display a string message using Servlets?

i dont no string for servlate


Write a program convert a string from uppercase to lower case and vice-versa without using string tolower and string toupper commands in TCL?

[ string toupper $str ] or [ string tolower $str ]


Write c program to print palindrome using string without using strrev strlen strcam?

sdfdg


How do you create a program using string?

You can use any text-editor, notepad is an example.


Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


Write a c program using string concept enter a sting and replace the new string in to old string and find no of occurrence?

print c co com comp compu


How do you generate a parse tree from an expression using C program?

c code for top down parser


String reverse program with single string and without using library functions in java?

You can create a separate string initially empty. Then using a loop, start at the end of the string and add it to the end of the other string. At the end of the loop, the other string would contain the reverse.


Assembly language program for string concatenation using 8086 microprocessor?

write program to concatenating two sting in 8086 assembly language


How do you tell your program you are using a VARIABLE?

You have to declare it. The simplest way to do so is by using the Dim keyword. For example if you want a string variable called someString you would declare it thus: Dim someString as string


Program to generate Fibonacci series using storage class in c plus plus?

i dn't know. haha