TCS DCA Coding Questions 27 September 2021, TCS Ninja (TCS NQT) to TCS Digital | PrepInstaTechBlog

TCS DCA Questions

In this blog post, TechBlog provides TCS DCA Coding Questions asked in the TCS Elevate Wings 1 Direct Capability Assessment (TCS DCA) conducted on 27 September 2021. This information is helpful to you in passing the Digital Capability Assessment Exam (TCS DCA Exam) and promotes you to Digital Cadre in TCS in September 2021.

Don't miss it! TCS DCA Questions 28th September 2021
Don't miss it! TCS DCA Questions 29th September 2021
Don't miss it! TCS DCA Questions 30th September 2021

 

TCS DCA Coding Questions 27 September 2021

TCS DCA Coding Questions September 2021 - 1:

Find total elements in the given array that is smaller than their adjacent numbers apart from the first A[0] and last element A[N-1] of the array. For example, Array A of n number of elements 0<= A[n] <= 50. Take first input n for the number of elements in the array. After that, take all the elements of the array separated by a new line. Now identify such elements so that, A[i-1] > A[i] < A[i+1].

Examples:

Input: [1,3,2,4,5]

Output: 1

Explanation: 

Only element 2 is satisfying the condition A[i-1] > A[i] < A[i+1] as 3>2<4. So the number of elements that satisfy the given condition is 1.

TCS DCA Coding Questions Answers - 1:

Solution:

TCS DCA Coding Questions Python

n = int(input())

list = []

for _ in range(n):

    list.append(int(input())

count = 0

for i in range(list):

    if i==0:

        continue

    if i==n-1:

        continue

    if list[i-1] > list[i] and list[i] < list[i+1]:

        count++


print(count)

TCS DCA Coding Questions September 2021 - 2:

Let us find out whether the sum of the digits of the given positive integer number N is UNO or not. Given a positive integer number N, reduce the number of digits of N by computing the sum of all the digits to get a new number. If this new number exceeds 9, then sum the digits of this new number to get another number and continue this way until a single digit value is obtained as the ‘digit sum’. The task here is to find out whether the result of the digit sum done this way is ‘1’ or not.

If the digit sum result is 1, display a message UNO If the digit sum is not 1, display a message NOT UNO

Example:

Input:
51112 –Value of N

So, 5+1+1+1+2 we get 10. Adding the digits again 1+0 we get the digit sum = 1, so therefore output will be “UNO”

Input:
The candidate must write the code to accept one input which Accepts value for N (positive integer number)


Output:
The output should print the message given in the problem statement (check the output in the above example)

TCS DCA Coding Questions Answers - 2:

Solution in C language:

//Solution by TechBlog

#include <stdio.h>

void main()
{
    int n,r,sum=0;
    scanf("%d",&n);
    while(n>0)
    {
        r=n%10;
        sum=sum+r;
        n=n/10;
    }
    if(sum%9==1)
    {
        printf("UNO");
    }
    else
    {
        printf("NOT UNO");
    }
}


TCS DCA Coding Questions September 2021 - 3:

Most modern aircraft are equipped with an autopilot system – one of the most useful features in fighter jets. In the beta testing of autopilot mode, one of the inputs is a string of literals containing the directions, which is fed into the flight computer before the take-off. The jet plane is put on an auto-landing mode that enables the plane to land automatically once all the directions in the string are complete Given the directions in the string str, the task here is to find out whether the jet plane returns to the same returns to the same position on the base where it took off.

  • Each direction in the string changes at an interval of 1 minute(1< = i <= N), where N is the number of directions in the input string
  • The directions are North (N), South(S), West(W), and East(E)
  • Display a message “Returned successfully” if the plane returns to the starting position.
  • Display a message “Not returned successfully” if the plane does not return to the starting position

Example 1:

Input: NESW-Value of str

Output: Returned successfully

Example 2:

Input: NNWESW-Value of str

Output: Not returned successfully

TCS DCA Coding Questions Answers - 3:

Solution in JAVA:

TCS DCA Coding Questions JAVA:

//Solution by TechBlog

import java.util.Scanner;

public class Technoname
{

	public static void main(String[] args)
	{

		Scanner sc = new Scanner(System.in); 
		String s =sc.nextLine();

		int N = 0, E=0, W= 0, S= 0 ,i; 
		
		for (i=0;i<s.length();i++)
		{

			if(s.charAt(i)=='N') 
			{
				  N++;
			}
			if(s.charAt(i)=='E')
			{
				E++;
			}
			if(s.charAt(i)=='W')
			{
				W++;
			}
			if(s.charAt(i)=='S')
			{
				S++;
			}
		}
		
		if( N==S && E==W )
		{
		System.out.println("Returned successfully");
		}
		else 
		{
			System.out.println("Not Returned successfully");
		}

	}
}

TCS DCA Coding Questions September 2021 - 4:

A ‘coin vend’ kiosk is installed in all the major metro stations The machine allows one to obtain cash of ‘R’ rupees in exchange for coins.

The machine operates with the following conditions:

  • Only coins of denomination 1 rupee and 2 rupees can be exchanged.
  • Coins of denomination 2 rupees should not be inserted successively twice.
  • The task here is to find all the possible combinations of the coins that can be inserted to get rupees from the kiosk Say, R=1, then only one coin of 1 rupee can be inserted to get 1 rupee

Example 1:

Input:

3- Value of R

Output:

3-Different ways to insert the coins to get ‘R’ rupees

Explanation:

The possible ways of inserting 1 rs and 1 rs coins for 3 rs in cash are

Way 1: (1,1,1)

Way 2 ‘: (2, 1)

Way 3 : (1, 2)

Example 2 :

Input:

5- Value of R

Output:

6 - Different ways to insert the coins to get ‘R’ rupees

Explanation:

Way 1: (1,1,1,1,1)

Way 2 : (2,1,1,1)

Way 3 : (1,1,1,2)

Way 4 : (1,1.2.1)

Way 5 : (1.2,1,1)

Way 6 : (2,1,2)

Constraints: 0 < R <= 50


Input:

The candidate has to write the code to accept 1 input -Accept value for N(positive integer number)

Output:

The output should be a positive integer number (Check the output in Example 1 and Example 2)

TCS DCA Coding Questions Answers - 4:

Solution in JAVA:

TCS DCA Coding Questions JAVA

//Solution by TechBlog

import java.util.Scanner;
class Technoname {
    static int CountCoin(int n)
    {
        if (n == 0) {
            return 1;
        }
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 1 + 1;
        }
        return CountCoin(n - 1) + CountCoin(n - 3);
    }
    
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        System.out.println(CountCoin(n));
    }
}

TCS DCA Coding Questions September 2021 - 5:

A physical education teacher asks students to assemble in a straight line for the morning assembly. In spite of repeated instructions, the students do not obey the teacher. Given an array of N number of arguments in which each element represents the height of the student in that position. The task here is to find the number of students, only for students numbered 1 to N -1(a[1] to a[N-1]), whose height is less than the height of their adjacent students.

Example 1:

Input: 5-Value of N

A[] = [35,15,45,25,55]. Elements A[0] to A[n-1] where each input element is separated by a new line

Output:

2 - Number of elements whose adjacent are greater than the element.

Explanation:

From the input array given above

A[0]=35
A[1]=15
A[2]=45
A[3]=25
A[4]=55

The elements whose adjacent values are greater are 15 and 25 as A[0] > A[1] < 45  (35 > 15 < 45) and A[2] > A[3] < A[4] (45 > 25 < 55).

Hence, the output is 2.

TCS DCA Coding Questions Answers - 5:

Solution in JAVA:

TCS DCA Coding Questions JAVA:

//Solution by TechBlog


import java.util.Scanner;
class Technoname 
{
	public static void main(String[] args)
	{
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = sc.nextInt();
        }
        int count=0;
        for (int i = 0; i < n-2; i++) {
            if (arr[i] > arr[i+1] && arr[i+2] > arr[i+1])
            {
                count++;
            }
        }
        System.out.println(count);
    }
}

TCS DCA Question numbers 1, 2, 3 were asked in the morning slot at 11 AM, and TCS DCA Exam Questions numbers 4 and 5 were asked in the evening slot at 4 pm.

For more, TCS DCA Coding Questions from the previous DCA Exam (Digital capability Assessment) are aggregated at TCS DCA Exam Coding Questions 2021.

Let us know other TCS DCA Exam Questions that you know which were previously asked on our mail contactus.techblog@gmail.com. Help others to clear TCS DCA Exam. You can get more questions using tcs dca mock test for TCS DCA September 2021.

Thanks for reading this TCS DCA Questions September 2021 and the Answers blog. Please share this article with your friends and colleagues as much as possible and help them to clear TCS DCA Exam. 

You can write to us your questions or feedback on our e-mail. Keep visiting, Stay updated with the latest trends.


Note: This information is gathered from public blogs and available on the Internet for free. We do not represent or affiliated with any company or organization. This is not an official blog of TCS. The reader should verify all the information before taking any action.

No comments:

Powered by Blogger.