Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

C# Online Test Questions Before Job Interview
#1

On and off I apply for C# Developer job. I do this to help my son who has recently done graduation in Computer Science. Applying for jobs give me the opportunity to test the job market for C# Developers. C# Developer market demand is high. When you apply for a job you have to pass an online test before you are interviewed. In this thread I will post possible test questions. This test question from TestGorilla asks you to add the even number elements in a list and subtract odd number elements and then return the total. We will consider 0 as an even number according to the question.

Code:
public static int Total (int[] number)
{

  int total=0;

  for(int i=0; i < number.Length; i++)
  {
    if(i==0) total=number[0];
    if(i%2==0) total+=number[i];
    else total -=number[i];

  }

  return total;



}

The second questions ask you to test a valid pin. A valid pin comprises 4 or 6 digits. The digits should be unique and the ATM PIN string is all digit. The method returns two string values The ATM PIN is valid or the ATM PIN is invalid. Below is the code for this method:
Code:
public static string ValidATMPIN (string ATMPIN)
{

  string message1="The ATM PIN is valid";
  string message2="The ATM PIN is not valid";
 
  //check that the ATMPIN is 4 digits or 6 digits
  if (ATMPIN.Length%4==0 || ATMPIN.Length%6==0)
  {
 
   //check that the ATMPIN contains only unique digits
    for ( int i=0; i < ATMPIN.Length; i++)
    {
   
      if ( ATMPIN[i] < 0 || ATMPIN[i] > 9)
      return message2;

      for(int j=i+1; j < ATMPIN.Length; j++)
      {
          if(ATMPIN[i]==ATMPIN[j]) return message2

      }   
   
   
    }
 
  return message1;
 
 
  }

Now I have coded this hastily. Go through the above code and if you find some error you can always leave a reply in this thread. The second question was meant to test your understanding of data structures.

Subscribe My YouTube Channel:
https://www.youtube.com/channel/UCUE7VPo...F_BCoxFXIw

Join Our Million Dollar Trading Challenge:
https://www.doubledoji.com/million-dolla...challenge/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)