TCS DCA Exam Questions and Answers, TCS NQT to TCS Digital | PrepInstaTechBlog

TCS DCA Questions


This blog by Tech Blog provides TCS DCA Exam Questions that were asked in the TCS Elevate Wings 1 Direct Capability Assessment (TCS DCA). This information is useful to you in clearing the Digital Capability Assessment Exam (TCS DCA Exam) and promote yourself to Digital Cadre in TCS. Tata Consultancy Service is the no. 1 IT Services company in India that conducts an exam for its employees to upgrade their existing package and cadre by clearing TCS DCA Exam. This blog explains and provides helpful information to clear the TCS DCA Test by providing TCS DCA exam questions with answers. You will get an idea about what type of questions and answers will be asked in the TCS DCA Exam.


TCS DCA was formerly called as TCS Digital. After clearing TCS DCA, You'll be upgraded from TCS NQT to TCS Digital cadre and get a revised package of around 7.5 LPA. It means tcs digital salary is around 7.5 Lakh CTC.


Cheers! Good News For recently joined TCS Associates as Tata Consultancy Service is going to conduct DCA (Direct Capability Assessment) again in September 2021. This is the third time TCS conducting DCA in 2021. It was organized in January and April previously.


Upcoming Assessment Date: 27th to 30th Sep


Eligibility Criteria for appearing in TCS DCA Exam


Full-time active employees in C1 or below grades with a total relevant experience of up to 3 years as of 31st Aug 2021 with Technical Qualifications

  • BE/B.Tech, ME/M.Tech
  • B.Sc/BCA and equivalent qualifications
  • M.Sc/MCA/MS and equivalent qualifications


TCS DCA Syllabus (TCS DCA Question Pattern):

  • Verbal Ability - 20 Questions (20 mins)
  • Numerical Ability - 15 Questions (30 mins)
  • Reasoning Ability - 15 Questions (30 mins)
  • Advanced Coding - 2 Questions (60 mins)


TCS DCA Exam Questions with Answers (TCS Elevate Wings 1 Coding Questions 2021):


TCS DCA Coding Questions - 1 :


Given string str which consists of only 3 letters representing the color,(H) Hue, (S) Saturation, (L) Lightness, called HSL colors. The task is to count the occurrence of ordered triplet “H, S, L” in a given string and give this count as the output.

This question was asked in April 21 Digital Capability Assessment

 

Example -1: 


Input

HHSL


Output

2


Explanation: There are two triplets of RGB in the given string: 

  • H at index 0, S at index 2 and L at index 3 forms one triplet of HSL.
  • H at index 1, S at index 2 and L at index 3 forms the second triplet of HSL.

Example -2:


Input: S = “SHL” 


Output: 0


Explanation: No triplets exist. 


Solution Approach

  1. Count the number of L(Light) in the given string and store the value in a Light_Count variable.
  2. Initialize Hue_Count = 0.
  3. Iterate over all characters of string from left to right.
  4. If the current character is (H)Hue, increase the Hue_Count.
  5. If the current character is (L)Light, decrease Light_Count.
  6. When the current character is S(Saturation) add Hue_Count * Light_Count in the result.

Solution in Java:


// Java code for the above program

class GFG{

// function to count the

// ordered triplets (H, S, L)  

static int countTriplets(String color)

{

int result = 0, Light_Count = 0;

int Hue_Count = 0;

int len = color.length();

int i;

// count the L(Lightness) 

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

{

if (color.charAt(i) == 'L')

Light_Count++;

}


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

{

if (color.charAt(i) == 'L')

Light_Count--;

if (color.charAt(i) == 'H')

Hue_Count++;

if (color.charAt(i) == 'S')

result += Hue_Count * Light_Count;

}

return result;

}


// Driver Code

public static void main (String[] args)

{

String color = "HHSSLLHSSLL";

System.out.println(countTriplets(color));

}


}


TCS DCA Coding Questions - 2 :


Check the length of a string is equal to the number appended at its last.

This question was asked in April 21 Digital Capability Assessment


Given a string that (may) be appended with a number at last. You need to find whether the length of string excluding that number is equal to that number. For example for “TechBlog8”, the answer is True as TechBlog consist of 8 letters. The length of String is less than 10000.


Examples : 


Input:  str = "Techn5"


Output:  Yes


Explanation: As Techn is of 5 lengths and at the last number is also 5.


Input:  str = "TechBlog15"


Output:  No


Explanation: As TechBlog is of 8 lengths and at last, the number is 15 i.e. not equal.


Solution Approach

  1. Traverse string from the end and keep storing the number till it is smaller than the length of the overall string.
  2. If the number is equal to the length of string except for that number’s digits then return true. 
  3. Else return false.

Solution in Java:


// Java program to check if the size of

// string is appended at the end or not.

import java.io.*;


class GFG {


// Function to find if given number is

// equal to length or not

static boolean isequal(String str)

{

int n = str.length();


// Traverse string from end and find the number

// stored at the end.

// x is used to store power of 10.

int num = 0, x = 1, i = n - 1;

for (i = n - 1; i >= 0; i--)

{

if ('0' <= str.charAt(i) &&

str.charAt(i) <= '9')

{

num = (str.charAt(i) - '0') * x + num;

x = x * 10;

if(num>=n)

return false;

}

else

break;

}


// Check if number is equal to string

// length except that number's digits

return num == i + 1;

}


// Drivers code

static public void main(String[] args)

{

String str = "TechBlog8";

if (isequal(str))

System.out.println("Yes");

else

System.out.println("No");

}

}


TCS DCA Coding Questions - 3:


Write a program to remove 7 and 56 from given string.

This question was asked in Jan 21 Digital Capababilty Assessment


Examples :


1) Given String : Tec7hBl56og


Output : TechBlog


2) String =Tec7h5Bl6og


Output : Tech5Bl6og


Solution in C Language:


#include <stdio.h>

#include <string.h>

int main()

{

   

char c[100] ="Tec7hno56Name";

int n=strlen(c);

int i;

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

{

if(c[i]=='7')

{

c[i] = '\0' ;

}

if(c[i]=='5' && c[i+1]=='6')

{

c[i] = '\0' ;

c[i+1]='\0';

}

}


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

{

printf("%c",c[i]);

}

    return 0;

}


TCS DCA Coding Questions - 4:


Write a program to find multiplication of a given number.

This question was asked in Jan 21 Digital Capabbilty Assessment


Input : 1234


Output Logic : 1*2*3*4= 24


Solution in C Language:


#include <stdio.h>

#include <string.h>

int main()

{

   int n=1234;

   int r,sum=1;

   while(n>0)

   {

       r=n%10;

       sum=sum*r;

       n=n/10;

   }

   printf("Sum is %d ",sum);

}


TCS DCA Coding Questions - 5:


You are given an array of prices where prices[i] is the price of a given stock on an ith day.


You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.

Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0


Example 1:


Input: prices = [7,1,5,3,6,4]


Output: 5


Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.

Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell.


Example 2:


Input: prices = [7,6,4,3,1]


Output: 0


Explanation: In this case, no transactions are done and the max profit = 0.


Solution in JAVA:


public class Solution {

    public int maxProfit(int prices[]) {

        int minprice = Integer.MAX_VALUE;

        int maxprofit = 0;

        for (int i = 0; i < prices.length; i++) {

            if (prices[i] < minprice)

                minprice = prices[i];

            else if (prices[i] - minprice > maxprofit)

                maxprofit = prices[i] - minprice;

        }

        return max profit;

    }

}


TCS DCA Coding Questions - 6:

5 . Given a string, consisting of alphabets and digits, find the frequency of each digit in the given string.


Input Format

The first line contains a string, which is the given number.


Constraints

All the elements are made of English alphabets and digits.


Output Format

Print ten space-separated integers in a single line denoting the frequency of each digit.


Sample Input

a11472o5t6


Sample Output

0 2 1 0 1 1 1 1 0 0


Solution in C language:

#include<stdio.h> 

#include<string.h>


int main ()

{

  char a[1000], freq[256] = {0};

  int i, n, j, count = 0;

  scanf("%[^\n]s", a); //input from user

  n = strlen(a); // finding string length

  char ch = '0';

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

    {

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

     {

     if (a[j] == ch)

     {

     count++;

     }

     }

      printf("%d ", count);

      count = 0;

      ch++;

    }


  return 0;

}


TCS DCA Coding Questions - 7:


You will be given an array of integers and a target value. Determine the number of pairs of array elements that have a difference equal to a target value.


For example, given an array of [1, 2, 3, 4] and a target value of 1, we have three values meeting the condition: 2-1 = 1, 3-2 = 1, and 4-3 = 1.


Function Description

Write a functioning pair. It must return an integer representing the number of element pairs having the required difference.

pairs have the following parameter(s):

  • k: an integer, the target difference
  • arr: an array of integers

Input Format

  • The first line contains two space-separated integers n and k, the size of arr and the target value.
  • The second line contains n space-separated integers of the array arr.

Sample Input

    5 2

    1 5 3 4 2 


Sample Output

   3


Solution

import java.util.*;

public class Main

{

    public static void main(String[] args)

    {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int k = sc.nextInt();

        int arr[] = new int [n];

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

            arr[i] = sc.nextInt();

        }

        int counter = 0; 

        Set<Integer> value = new HashSet<Integer>();

        for(int i : arr){

            value.add(i);

        }

        for(int i : value){

            if(value.contains(i + k)){

                ++counter;

            }

        }

        System.out.println(counter);

    }

    }


TCS DCA Coding Questions - 8:


Write a program to find the count of numbers that consists of unique digits.


Input:

Input consists of two Integer lower and upper values of a range


Output:

The output consists of a single line, print the count of unique digits in a given range. Else Print ”No Unique Number Found


Solution in C language:

Input –

10

15

#include<bits/stdc++.h> 

using namespace std; 

  

 

void printUnique(int l, int r) 

    int count=0;

    for (int i=l ; i<=r ; i++) 

    { 

        int num = i; 

        bool visited[10] = {false}; 

  

        while (num) 

        { 


            if (visited[num % 10]) 

                break; 

  

            visited[num%10] = true; 

  

            num = num/10; 

        } 


        if (num == 0) 

            count++; 

    }

    if(count>0)

     cout<<count;

    else

        cout<<"No Unique Number";

  

int main() 

    int l,r; 

    cin>>l>>r;

    printUnique(l, r); 

    return 0; 


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.

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

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


You'll get access to tcs dca coding questions java, tcs dca questions 2021, tcs dca coding questions github, tcs dca questions and answers pdf, tcs dca question pattern, tcs dca coding questions python, tcs dca coding questions geeksforgeeks, dca coding questions tcs, tcs direct capability assessment questions, dca exam in tcs, dca test tcs.


Write to us about your questions or feedback. 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.