Tejas Networks Interview Question for Software Engineer / Developers


Country: India




Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{
 int i, j;
 char * str = (char *)malloc(256);
 
 printf("get string :");
 scanf("%s", str);

 // first reverse entire string
 revere_string(str, 0, strlen(str) - 1);

 for(i = 0; i < strlen(str) - 1;)
 {
   // skip spaces, tabs & nul's
   while(str[i] == 0x00 || str[i] == 0x20 || str[i] == '\t')
   {
      i++;
   }
   // mark start of alpha-num char
   j = i++;

   // find end of alpha-num word
   while(!(str[i] == 0x00 || str[i] == 0x20 || str[i] == '\t'))
   {
      i++;
   }
   // reverse the word
   reverse_string(str, j, i - 1);
 }
 puts("after word by word reversal :");
 puts(str);
}

- coder October 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Stack of words will solve the problem. e.g., take stack<string> and take space as a delimiter, --> start pushing the words and the popup again to reverse the word order.

- Victor October 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main() {
const char * s = " he is a geek ";

int len = strlen(s);
int i = len-1;
int j;

while (1) {
while (i>=0 && s[i] == ' ') i--;
if (i<0) break;

j=i;
while (i>=0 && s[i] != ' ') i--;
for (int k=i+1; k<=j; k++) printf("%c", s[k]);
printf(" ");
}
printf("\n");
}

- Anonymous October 14, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More