Visit our sponsor Granny's Eggs  
Home
Microsoft Interview Process
Microsoft HR Questions
Technical Questions
Puzzles/Riddles
Resume Tips and Template
Discuss
Question to Interviewer
Interview Tips
Term Of Use
Site Feedback


Reverse a string

 

Comments:

Reverse a String Using Recursive function
By sasikumardr on Monday, June 30, 2008 (UMST)
I will write a C function to accomplish this task void Reverse(char *s) { if(*s!='\0') Reverse(s+1); printf("%c",*s); } void main() { char *str="Hello"; Reverse(str); }

Reply to this Comment
 

Reverse
By imnotageek on Sunday, August 03, 2008 (UMST)
You are not reversing the string!

Reply to this Comment
 

Reverse
By imnotageek on Sunday, August 03, 2008 (UMST)
/* Iterative algorithm */ void revers(char **str) { char *temp = *str; int t = 0; while(*temp!='\0') { cout<<*temp; temp++; t++; } temp--; for(int i = 0; i < (t / 2); i++) { char te = *(*str+i); *(*str+i) = *(temp - i); *(*str + (t - i - 1)) = te; } return; }

Reply to this Comment
 

Recursion
By rprabhak on Saturday, September 20, 2008 (UMST)
void ret_str(char* string) { if(*string != '\0') ret_str(string+1); cout<<*(string); } int main() { ret_str("microsoft"); }

Reply to this Comment
 

Reverse String Recursively
By PrinceOfWildCats on Wednesday, October 01, 2008 (UMST)

char* StringConcat(char* szConCatInput, char End)
{
 if(!szConCatInput)
 {
  szConCatInput = new char();
  szConCatInput[0] = End;
  szConCatInput[1] = '\0';
 }
 else
 {
  int len = strlen(szConCatInput);
  szConCatInput[len] = End;
  szConCatInput[len+1] = '\0';
 }
 return szConCatInput;
}
char* ReverseStringRecursion(char* szInput)
{

 char buf;
 buf = szInput[0];
 if(!buf)
 {
  return '\0';
 }
 char* a = ReverseStringRecursion(++szInput);
 
 char* ret = StringConcat(a,buf);
 return ret;
}

Reply to this Comment
 

Recursive Reverse
By yogi_1306 on Saturday, October 11, 2008 (UMST)
#include<stdio.h> #include<string.h> #include<stdlib.h> char *reverse(char *str,int length,char *temp); int main(){ char *string = "Hello"; char *tempstr = malloc(sizeof(strlen(string))); if(tempstr==NULL){ printf("Failed to assign memory"); exit(0); } reverse(string,strlen(string)-1,tempstr); printf("%s\n",tempstr); free(tempstr); free(string); return 0; } char *reverse(char *str,int length,char *temp){ if(length<0){ temp[strlen(str)]='\0'; printf("%s\n",temp); return temp; } else{ temp[(strlen(str)-1)-length]=str[length]; reverse(str,length-1,temp); } }

Reply to this Comment
 

Add Your Comment

New Articles
  • Phone screen from MICROSOFT Denmark for SDET
    Technical Phone screen after Escreen

  • Please post some non-tech qs for User Experience and Business Analyst job

    I am a CS Grad applied in non-tech position.Please help!


  • Combinations in a character array.
    Write a program that takes input a char array and outputs all the combinations of the characters in the character array.
    Example: consier char array {'a','b','c'}
    the output shouold be abc,cab,bac,acb,cba,bca that is all the combinations of characters 'a','b','c'.


  •  

    Most Popular Articles
  • Crazy Guy On The Airplane
    A line of 100 airline passengers is waiting to board a plane. they each hold a ticket to one of the 100 seats on that flight.

  • What are your greatest weaknesses
    Beware - this is an eliminator question, designed to shorten the candidate list. Any admission of a weakness or fault will earn you an “A” for honesty, but an “F” for the interview.

  • Question: Tell me about yourself.
    Many candidates, unprepared for the question, skewer themselves by rambling, recapping their life story, delving into ancient work history or personal matters.

  •  

    New Posts

  • male enhancment buy viagra tramadol online
    Posted by SurojattSit on 2008年9月30日 (UMST)

  • penis enlargement viagra cheap tramadol
    Posted by BobeCrobChext on 2008年9月30日 (UMST)

  • penis viagra online Tramadol
    Posted by BobeCrobChext on 2008年9月30日 (UMST)



  •