Tech Mahindra 1st April 2021 Asked in All 6 Shifts Complete Question Papers | All Batch Asked Coding Question with Solution


Tech Mahindra Today Asked in All 6 Shifts  Complete Question Papers
Tech Mahindra Today Asked in All 6 Shifts  Complete Question Papers


Join Our WhatsApp Group

Tech Mahindra Today Asked in All 6 Shifts  Complete Question Papers:

Tech Mahindra Today Asked in All 6 Shifts  Complete Question Papers | All Batch Asked Coding  Question with Solution

Are Questions Repeat? | Is WebCam is There? Can We Switch the Tab? Is Pen Paper Allowed?

TECH MAHINDRA ALL CODING SOLUTIONS:


1. Write a program to calculate and return the sum of distances between the adjacent number in an

array of positive integers.

https://t.me/placemate

Note: You are expected to write code in the find total distance function only which receives the

first parameter as the numbers of items in the array and the second parameter is the array itself. You

are not required to take the input from the console.

Example Finding the total distance between adjacent items of a list of 5 numbers.

Input

input 1: 5

input 2 : 10 11 7 12 14

Output

12

Explanation

The first parameter 5 is the size of the array. Next is an array of integers. The total of

distances are 12 as per the calculation below.

10 – 11 = 1

11 – 7 = 4

7 – 12 = 5

12-14 = 2

Total Distance = 1 + 4 + 5 + 2= 12

Solution:

def findTotalDistance(n,numbers):

total = 0

for i in range(n-1):

total+= abs(numbers[i]-numbers[i+1])

return total

n = int(input())

https://t.me/techmahindra2021crack

numbers = list(map(int, input().split()))

print(findTotalDistance(n,numbers))

2. CALCTOTALTAX

calculate total tax for a list of 5 billing amounts

solution

#include <stdio.h>

int main()

{

int i=0,sum=0,total_bill=0,tax_amount=0,n,m[100];

scanf("%d",&n);

for(i=0;i<n;i++)

{

scanf("%d",&m[i]);

}

for(i=0;i<n;i++)

{

sum=sum+m[i];

https://t.me/placemate

}

if(sum>1000)

{

tax_amount=(sum-1000)/10;

}

total_bill=total_bill+tax_amount;

printf("%d",total_bill-400);

}

3. FINDODDEVENDIFFERENCE

SOLUTION:

def findEvenOddDifference(n,numbers):

total=0

for i in numbers:

if i%2 == 0:

total-=i

else:

total+=i

return total

n = int(input())

https://t.me/techmahindra2021crack

numbers = list(map(int,input().split()))

print(findEvenOddDifference(n,numbers))

4. FINDMAXDIFFERENCE

SOLUTION in python:

def findMaxDifference(n,numbers):

maximum = 0

for i in range(n-1):

if numbers[i] - numbers[i+1] > maximum:

maximum = numbers[i] - numbers[i+1]

return maximum

n = int(input())

numbers = list(map(int, input().split()))

print(findMaxDifference(n,numbers))

SOLUTION IN C:

https://t.me/placemate

#include <stdio.h>

int findMaxDifference(int n, int arr[])

{

int difference, max = 0;

for(int i=0; i<n-1; i++)

{

difference = arr[i]-arr[i+1];

if(difference > max)

{

max = difference;

}

}

return max;

}

int main()

{

int n;

scanf("%d",&n);

int array[n];

for(int i=0; i<n; i++)

{

scanf("%d",&array[i]);

}

int result = findMaxDifference(n, array);

printf("%d",result);

return 0;

}

https://t.me/freshersoffcampjobs

5. FindTotalFeet

CODE IN C:

#include <stdio.h>

int findTotalFeet(int n, int arr[])

{

int feet, total = 0;

for(int i=0; i<n; i++)

{

feet = arr[i] / 12;

total = total + feet;

}

return total;

}

int main()

{

int n;

scanf("%d",&n);

int array[n];

for(int i=0; i<n; i++)

{

scanf("%d",&array[i]);

}

int result = findTotalFeet(n, array);

printf("%d",result);

return 0;

}

CODE IN PYTHON

def findTotalFeet(n,numbers):

total = 0

for i in numbers:

total += i//12

return total

n = int(input())

numbers = list(map(int, input().split()))

print(findTotalFeet(n,numbers))

findLargeSmallDifference CODE IN C:

#include <stdio.h>

https://t.me/placemate

int findLargeSmallDifference(int n, int array[])

{

int small = array[0], large = 0;

for(int i=0; i<n; i++)

{

if(array[i]>large)

{

large = array[i];

}

if(array[i]<small)

{

small = array[i];

}

}

return large-small;

}

int main()

{

int n;

scanf("%d",&n);

int array[n];

for(int i=0; i<n; i++)

{

scanf("%d",&array[i]);

}

int result = findLargeSmallDifference(n, array);

printf("%d",result);

return 0;

}

Tech Mahindra - Max difference code:

#include <stdio.h>

int findTotalCurtains(int n, int arr[])

{

    int feet, total = 0;

    for(int i=0; i<n; i++)

    {

        feet = arr[i] / 12;

        total = total + feet;    

    }

    return total;

}

int main()

{

    int n;

    scanf("%d",&n);

    int array[n];

    for(int i=0; i<n; i++)

    {

        scanf("%d",&array[i]);

    }

    int result = findTotalCurtains(n, array);

    printf("%d",result);

    return 0;

}

Tech mahindra code :

No. of items in the array

import java.util.*;

public class Main

{

https://t.me/placemate

 public static void main(String[] args) {

    Scanner sc =new Scanner(System.in);

    int size = sc.nextInt();

        int f=0,i,rem = 0;

https://t.me/freshersoffcampjobs

    int a[]  = new int[size];

    for(i =0;i<size;i++){

       a[i] = sc.nextInt(); 

    }

    for(i=0;i<size;i++){

        if(a[i]>=12){

            rem = a[i]/12;

            f=f+rem;

        }

    }

    System.out.println(f);

 }

}

Tech Mahindra code :

No. of items in array

import java.util.*;

public class Main

{

 public static void main(String[] args) {

    Scanner sc =new Scanner(System.in);

    int size = sc.nextInt();

        int f=0,i,rem = 0;


    int a[]  = new int[size];

    for(i =0;i<size;i++){

       a[i] = sc.nextInt(); 

    }

https://t.me/techmahindra2021crack

    for(i=0;i<size;i++){

        if(a[i]>=12){

            rem = a[i]/12;

            f=f+rem;

        }

    }

    System.out.println(f);

 }

}

import java.util.*;

public class Main

{

 public static void main(String[] args) {

    Scanner sc =new Scanner(System.in);

    int size = sc.nextInt();

        int f=0,i,rem = 0;

https://t.me/freshersoffcampjobs

    int a[]  = new int[size];

    for(i =0;i<size;i++){

       a[i] = sc.nextInt(); 

    }

    for(i=0;i<size;i++){

        if(a[i]>=12){

            rem = a[i]/12;

            f=f+rem;

        }

    }

    System.out.println(f);

 }

https://t.me/placemate

}

How To Apply for Download PDF:  
 
All candidates can download here:

Join Our Whats App Group

Step#1: Go to the above link, Join Our What's App Group.

Note: If Already Joined, Directly Apply Through Step#3.

Step#2: Also Join Our All Telegram and What's App Group for Free! DONE!

Step#3: Apply Link: Click Below Link To Apply

Download Link: Click here (PDF Link)

Note: Apply for The Job Before Link Expires.

Also, Read More about this: 

Also, apply for other jobs,

TCS March Latest NQT Interview Experience 2021


Tips to Follow to Crack Tech Mahindra Exam 2021

CTS - Cognizant 96 Important Interview Questions 2021

TCS Ninja and Digital 2021 All Interview Questions

Hexaware technical interview 2021 

Stay tuned with www.freshersocjob.com to receive more such updates on recruitment. Join our Telegram Channel and Join our WhatsApp Group To get Instant updates for All Recruitment Internships and Off-Campus of 2021 Pass-Out Batch and Other Batch.


Comments