Sunday 20 December 2015

Mindtree Interview Experience

My experience in the mindtree Programming test!


We had gone in to a college where students from different colleges had come.
We had to choose any one of three different programming languages being C,C++, and Java.
I went with my strength and chose C.

The two programs that were given to me were.

1. To implement a function that will take two numbers num1 and num2 where num1 is single digit number and num2 can be assumed to be a larger one. We need to count the number of occurences of num1 in num2.

My logic was pretty simple for this program.

getnumber(int num1,int num2)
{
int rem,a;
while(num2<0)
{
rem=num2%10;
if(num1==rem)
{
a++;
}
num2=num2/10;
}
return(a);
}


2. The second question was a pattern based question. The pattern was :-

Given that N=4
The desired pattern would be:

1*2*3*4
9*10*11*12
13*14*15*16
5*6*7*8

This was kinda tricky for me. I have been trying to crack it but i am open to solutions for this one. 

2 comments:

  1. #include

    int main()
    {
    int a=4;
    int b,i;
    printf("Enter a Number:");
    scanf("%d",&b);
    for(i=0;i<a;i++){
    printf("%d*",b);
    b++;
    }

    return 0;
    }

    ReplyDelete
  2. For custom number:

    #include

    int main()
    {
    int a;
    int b,i;
    printf("Enter the size of pattern:");
    scanf("%d",&a);
    printf("\nEnter a Number:");
    scanf("%d",&b);
    for(i=0;i<a;i++){
    printf("%d*",b);
    b++;
    }
    return 0;
    }

    ReplyDelete