soni.komal712
BAN USERArithmatic operator is used to add while processing.
- soni.komal712 August 06, 2015Hi, I think following code serves the purpose:
char * strcpy(char * target, const char * source)
{
char * destination = target;
while ((*destination++ = *source++) != 0)
;
return (destination);
}
Function parameters include source and target, both pointers to char or char array. source remains unchanged while processing so it is declared as const.
It returns char * therefore it can be used directly in printf() like functions.
Yes it has been assumed that destination string is large enough and initialized, else there would be foloowing problems:
-->It might be pointing at memory you don't have access to, in which case it causes a segmentation fault and crashes your program
--> It might be pointing at real data, and if you don't know what it's pointing to, you're causing unpredictable (and very hard to debug) changes to your data.
-->You have no way of knowing if it's been initialized or not - because how do you tell the difference between a valid address and the address that happened to be there when you declared the pointer?
Hi,
It can be easily solved using following code:
--->i=0,m=0;
--->end=length(source)
--->while(i<length(source))
lengthWord=0
while(source[i]!=' ')
lengthWord++
i++
for(j=0;j<lengthWord;j++)
target[m]=source[end]
m++
end--
target[end--]=' '
i++
Hi,
It can be solved following the same steps as taken in BFS.
Here is a simple pseudo-code for the same:
First parameter is 'source' and the second parameter is 'target'
SourceToTarget(String source, String target)
---> Create Stack (stack)
--->Push source(String) to stack
--->while(!isStackEmpty(stack))
newWord=Pop(stack)
if(newWord!=target)
for(i=0;i<length(newWord))
presentChar=newWord.charAt(i)
for(letter= 'A' to 'Z')
if(letter==presentChar)
continue
newWord.charAt(i)=letter
if(existsInDictionary(newWord))
Push(newWord)
else
break;
a.) would maximize his chances to reach office early
- soni.komal712 August 18, 2015Total cases=10
a.)probability=probability of driving red car *probability of listening to POP music * probability of reaching office early on friday = 4/10 * 4/10 * 3/10=0.048
b.)probability=probability of driving blue car *probability of listening to rock music * probability of reaching office early on teusday= 3/10 * 3/10 * 3/10=0.027