Microsoft Interview Question for Web Developers






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

void reverse_string(char * string) 
{
	int n = strlen(string); // number of characters in the string
	for(int i = 0; i < n; ++i) {
		if((string[i] >= 'a') && (string[i] <= 'z')) {
			string[i] -= 32;
		} else if((string[i] >= 'A') && (string[i] <= 'Z')) {
			string[i] += 32;
		}
	}
	return;
}

- zdmytriv March 13, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

public StringBuilder RetrunReverseStringCase(string value)
        {
            StringBuilder str = new StringBuilder();
            foreach (char c in value)
            {
                if (char.IsLetter(c))
                {
                    int numberEq = Convert.ToInt32(c);
                    if (c > 90)
                    {
                        numberEq = numberEq - 32;
                    }
                    else
                    {
                        numberEq = numberEq + 32;
                    }

                    str.Append(Convert.ToChar(numberEq));
                }
                else
                {
                    str.Append(c);
                }
            }
            return str;
        }

- Dilip April 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

you don't need to use strlen.
you can use
while(*string!='\0')

- freemail165 September 30, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

string Reverse(string toReverse)
{
var sb = new StringBuilder();
for(int i = 0; i < toReverse.Length; i++)
{
if (toReverse[i].ToString() == toReverse[i].ToString().ToUpper())
{
sb.Append(toReverse[i].ToString().ToLower());
}
else
{
sb.Append(toReverse[i].ToString().ToUpper());
}
}
return sb.ToString();
}

- Mark January 04, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

unction revString(sample){
    var revSample="";
    var i=0;
    while(i<sample.length){
        if(sample.charAt(i)==(sample.charAt(i)).toUpperCase()){
           revSample= revSample.concat((sample.charAt(i)).toLowerCase());
        }else{
            revSample=revSample.concat((sample.charAt(i)).toUpperCase());
        }
     i++;   
    }
    return revSample;
}
var x=revString("Hello World");
alert(x);

- javascript code March 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In PHP:

<?php
function revString($sample){

$revSample = "";
$i=0;
while($i<strlen($sample)){
if($sample{$i} == strtoupper($sample{$i})){
$revSample = $revSample.(strtolower($sample{$i}));
}else{
$revSample=$revSample.(strtoupper($sample{$i}));
}
$i++;
}
return $revSample;
}
$x = revString("hELLo wOrLd");
echo $x;
?>

- Anonymous March 21, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[20];
int i,j,k,n;
clrscr();
printf("enter string\n");
gets(str);
for(i=0;str[i]!=0;i++)
{
if(str[i]>=65&&str[i]<=90)
str[i]+=32;
else if(str[i]>=97&&str[i]<=122)
str[i]-=32;
}
printf("new string\t");
puts(str);
getch();
}

- Sikandar Kumar October 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice code

- xxx October 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main (String[] args) throws java.lang.Exception
	{	
		String str = "hELLo wOrLd1";
		StringBuilder builder = new StringBuilder();
		char[] chars = str.toCharArray();

		for(int i = 0; i < chars.length; i++) {
			if(Character.isLetter(chars[i]) && Character.isLowerCase(chars[i])) {
				builder.append(String.valueOf(chars[i]).toUpperCase());
			} else {
				builder.append(String.valueOf(chars[i]).toLowerCase());
			}
		}
		
		System.out.println(builder.toString());
	}

- Anuj K November 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public StringBuilder RetrunReverseStringCase(string value)
        {
            StringBuilder str = new StringBuilder();
            foreach (char c in value)
            {
                if (char.IsLetter(c))
                {
                    int numberEq = Convert.ToInt32(c);
                    if (c > 90)
                    {
                        numberEq = numberEq - 32;
                    }
                    else
                    {
                        numberEq = numberEq + 32;
                    }

                    str.Append(Convert.ToChar(numberEq));
                }
                else
                {
                    str.Append(c);
                }
            }
            return str;
        }

- dilip April 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

in JavaScript

function invertCase(text) {
  return text
           .split('')
           .map(char => char === char.toLowerCase() ? char.toUpperCase() : char.toLowerCase())
           .join('');
}

- Fernando March 17, 2017 | 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