Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
Practice Tech Mahindra Essay Topics

Programming Questions and Answers

    281 / 404

    You have a job in which you have to take time stamps and store them. So Write a data structure that can minimize the storage requirements of Year, Month, Date, Hour, Minute.

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:Virtusa

    282 / 404

    Write a program to find the four digit numbers, which are perfect squares, and all the digits in that number are even.

    Input : NA


    Output : NA

    View Answer |  Strings |  Practice Program | Add to Reading List To Reading List | Asked In Virtusa |  Fresher
    Please Login to view the answer

    Tags:Virtusa

    283 / 404

    Start from a random number, generate a sequence such that if number is odd multiply it 3 and add 1. If number is even, divide the number by 2. This Sequence will always cyclic with 4, 2, 1. In this sequence, find the maximum power of 2 generated in the sequence and print only the power, not the sequence.

    Input : NA


    Output : NA

    View Answer |  Hashing |  Practice Program | Add to Reading List To Reading List | Asked In Virtusa |  Fresher
    Please Login to view the answer

    Tags:Virtusa

    284 / 404

    Start with a random 2 digit number, The series is generated by multiplying the number by 2 and placing the last 2 digits as the next number. Series continues until one of the element repeats.

    Input : NA


    Output : NA

    View Answer |  Hashing |  Practice Program | Add to Reading List To Reading List | Asked In Virtusa |  Fresher
    Please Login to view the answer

    Tags:Virtusa

    285 / 404

    Write a program to print all the four digit numbers whose squares must have all the even digits.

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:Virtusa

    286 / 404

    Write a program to print the pyramid up to the passed integer value.

    1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 . .

    If we pass the value 13 it should print like the above (no need to print the 3 dots)

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:Virtusa

    287 / 404

    Write a function which takes one string S, one character X, one more Character Y, which should return the longest substring in the String S, which starts with the X and ends with Y?

    Input : NA


    Output : NA

    View Answer |  Strings |  Practice Program | Add to Reading List To Reading List | Asked In Virtusa |  Fresher
    Please Login to view the answer

    Tags:Virtusa

    288 / 404

    Write a program to accept two time stamps in the given format HH:MM:SS using apropriate datatypes and find the difference between the time stamps in seconds.

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:Virtusa

    289 / 404

    Write a function to accept a number 'n' and
    a)if n is negative then return -1.
    b)if n is positive and perfect number then return sqrt(n).
    c)if n is positive and not a perfect no. then return n(n+1)/2

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:Virtusa

    290 / 404

    Write a program to print in the format

    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:Virtusa