Monday, May 24, 2010

Anybody genius in c++ programming .This question is specially to them........?

Describe about c-strings in c++ programming .mention its functions


and also advantages of using these strings while programming....

Anybody genius in c++ programming .This question is specially to them........?
Hope this will help u


http://www.cprogramming.com/tutorial/les...
Reply:What are c-strings?
Reply:You don't need to be a genius to answer that.





Don't be so specific like that - give _everyone_ an opportunity to help you. Otherwise it's called "looking a gift horse in the mouth".





Rawlyn.
Reply:yes indeed


How to check for anagrams in C++?

I need a program to check two entered strings of text and see if the strings entered are anagrams, disregarding the case of the letters, and ignoring spaces (i.e. "Mother in Law" and "Woman Hitler" are anagrams). The strings won't be any longer than 500 characters.





I can't figure out what to do with this because it has to use arrays, which I have never been good with, and the emphasis is supposed to be on use of c strings.





I do know that it essentially needs to do this: change the case of the two strings and remove anything that isn't a letter, then sort the letters, and finally determine if they are the same (are they anagrams?).





I'm trying to keep this "simple." Can anyone help me with a program that does this? Thanks SO MUCH in advance!

How to check for anagrams in C++?
Well, in programming, we always try to get a clear problem definition and logical solution before we start coding.





Oh wait...I was thinking of a palindrome...





Answering questions for people is like programming. We should think 1st. :-)





Yes, sorting is a good idea. And so is changing case....changing case before the sort will enable a clean sort...





1 - Change both strings to lowercase with _strlwr( char *string );





2 - sort both strings... see qsort() for a cheap easy solution that your compiler probably already has. All mine have had qsort().





3 - kill whitespace. You mite need to build a function for this...but qsort should have moved all the whitespace to the end (or begining) which makes it easier (especially if at end).


- You can kill trailing whitespace very easily by putting a null '\0' at the very first instance of white space, if whitespace is at the end, like so:


for(ii=0; ii%26lt; strlen(string); ii++)


if(string[ii] == ' ') // a space?


{


string[ii] = '\0'; ///kill it and cap the string


break; // we're done


}








4 - compare the two strings with strcmp(). If they match, they're anagrams





That's our flow plan and function ID.
Reply:so its a "string compare" your doing ? ;-)





on the first one, u could have a pointer.. basically u check a letter against the second string...





you either have true / false... you need a recurssive loop that checks till end of line / null





it will either return TRUE and exit that loop.. then get ++ the string1 .. and repeat scanning string2..





if it returns false, after the end of string2... obviously they aren't the same..





i would have an array or struct, with a flag in for each character.. 1 exists.. 0 doesn't exsist





then print results.. eg..





found =


not same letters =





and no i'm not gonna do the code, u've had enough clues to do ya own homework =)
Reply:It is not that easy. May be you can contact a C++ expert at websites like http://askexpert.info/


Strings in C#?

if a user enters the expression in a textbox e.g 3 + 5


what is the code in c# that will take the string and evaluate


the expression?

Strings in C#?
See the code here:


http://www.codeproject.com/KB/cs/evalcsc...





It shows how to implement an "eval" function that inputs a string and evaluates it as code. If it's added to your project with the imports, you could do something like:





MessageBox.Show(eval("3+4;").toString(...





If all you need to do is add numbers though, it's overkill and it would be better to scan through the string for the "+" and extract the numbers on opposite sides.
Reply:Tryparse(textBox1-%26gt;Text,num1);


Tryparse(textBox2-%26gt;Text;num2);


num3=num1*num2;





textBox3-%26gt;Text=num3.toString();


or


MessageBox(num3.toString());


If I am using cin<<x; (in C++) where x is char[20] then x takes value only before space. How 2 get full string

Firstly its cin%26gt;%26gt;


u'll also need the command getline()


Im not going to give everything away but u shld be able to figure it from here !

If I am using cin%26lt;%26lt;x; (in C++) where x is char[20] then x takes value only before space. How 2 get full string
First of all, it's cin %26gt;%26gt; x. cout %26lt;%26lt; goes to the left, cin to the right.





Second, use cin.getline to get a full string.

wedding

Can someone give me an algorithm in C# to obtain and get the number of occurences of a unique char in a string

You can use regular expressions or a series of IndexOf calls.





Assuming,


string searchString = "abcbdefb";


char charToFind = 'b';





Regular Expressions:


int numberOfChars = System.Text.RegularExpressions .Regex.Matches( searchString, charToFind.ToString() ).Count;





IndexOf:


int numberOfChars = 0;


int lastIndex = 0;


while(lastIndex %26lt; searchString.Length %26amp;%26amp; lastIndex %26gt; -1)


{


lastIndex = searchString.IndexOf( charToFind, lastIndex + 1);


if (lastIndex == -1) break;


numberOfChars++;


}

Can someone give me an algorithm in C# to obtain and get the number of occurences of a unique char in a string
Well for VB, its like Len("msg") or Len(TextBox1.Text) and it tells you how many characters are in that text box.


Is there c# program to convert 4 digit no to 4 thousand 6 hundred 3 ten 2 unit manner without using any string

how to convert 4 digit number to the following example?


Example. 4632 want to convert 4 thousand 6 hundred 3 ten 2 unit

Is there c# program to convert 4 digit no to 4 thousand 6 hundred 3 ten 2 unit manner without using any string
#include%26lt;stdio.h%26gt;


void main()


{


int num,n1,n2,n3,n4;


printf("\nEnter 4 digit number");


scanf("%d",num); //ex4632





n1 = num/1000; //n1=4


n2 = (num/100)%10 //n2=6


n3 = (num/10)%10 // n3=3


n4 = num % 10 // n4 = 2





printf("\n %d = %d thousand %d hundred %d ten $d unit",num,n1,n2,n3,n4);


}





This is the only sensible solution dude.
Reply:Without using string it is not possible. otherwise the question is incomplete try to explain it with more details.
Reply:Without using a string? Ouch. How would you store the literal string "thousand" without using a string? You'd probably have to output it one character at a time, 't', 'h', 'o', 'u'....





In fact, the "string" type was created specifically so you didn't have to do that sort of silly char-at-a-time stuff. Why are you trying to do it the hard way? A sadistic professor? :)


Can anybody help me in coding in c to arrange the words in ascending order of word length given in a string?

Quicksort

Can anybody help me in coding in c to arrange the words in ascending order of word length given in a string?
Yes just sort it.
Reply:find the length of the string using strlen and sort the words using any sorting technique(Bubble sort)