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

TCS DCA Coding Questions 2021


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.

TCS DCA was formerly called 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.

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

In this blog post, TechBlog provides TCS DCA Coding Questions asked in the TCS Elevate Wings 1 Direct Capability Assessment (TCS DCA) conducted on 29 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.


TCS DCA Coding Questions 29 September 2021

TCS DCA Coding Questions 29th September 2021 - 1:

A man has money/coins in two different bags. He visits the market to buy some items. Bag A has N coins and bag B has M coins. The denominations of the money are given as array elements in a[] and b[]. He can buy products of by paying an amount which is an even number by choosing money from both the bags. The task here is to find the number of ways the man can buy items such that the product of money from both the bags is an even number.

The man has to pick one coin at least from each bag to make an even number product.

Example 1:

Input:

3- Value of N
3- Value of M
(1,2,3)-a[], Elements a[0] to a[N-1], where each input element is separated by new line

(5,6,7)-b[], Elements b[0] to b[N-1], where each input element is separated by new line

Output:

5-Number of ways

TCS DCA Coding Questions Answers - 1:

Solution:

TCS DCA Coding Questions C++

//Solution by PrepInstaTechBlog

#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n1,n2;
    cin>>n1;
    cin>>n2;
    int c=0;
    vector<int> v1(n1),v2(n2);
    
    for(int i=0;i<n1;i++)
        cin>>v1[i];
        
    for(int i=0;i<n2;i++)
        cin>>v2[i];
    
    for(int i=0;i<v1.size();i++)
    {
        for(int j=0;j<v2.size();j++)
        {
            if((v1[i]*v2[j])%2==0)
                c++;
        }
    }
    cout<<c;

    return 0;
}

TCS DCA Coding Questions 29th September 2021 - 2:

There are 26 chairs that need to be arranged for a ceremony. The chairs are named from A to Z . Every chair should be arranged according to the ordinal number of the letter in the English alphabet. Due to some misunderstanding, the chairs are randomly arranged. Given a str, the task here is to find the number of chairs which are correctly placed as per the ordinal number of the letters as given below.

The same positions apply for both uppercase and lower case letters.

Example 1:

Input:

Value of str= abcxyz

Output

Number of chairs that are correctly placed as 3 per ordinal position of the letters of the English alphabet

Explanation :

From the inputs given above: Letters a, b and c are in the correct positions 1, 2, and 3, respectively Rest of the letters are not in the correct positions.
Hence, the output is 3.

Example 2:

Input:

Value of str= abcxyzgh

Output:

5 – Number of chairs that are correctly placed as per the ordinal position of the letters of the English alphabet.

TCS DCA Coding Questions Answers - 2:

Solution:

TCS DCA Coding Questions JAVA

//Solution by PrepInstaTechBlog

import java.util.Scanner;
public class PrepInstaTechBlog
{
	public static void main(String[] args) 
	{
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		int count=1;
		for(int i=1;i<str.length();i++)
		{
			if(str.charAt(i)==str.charAt(0)+i)
			count++;
		}
		System.out.println(count);
	}
}

TCS DCA Coding Questions 29th September 2021 - 3:

Numbers are everywhere around us. We deal with different types of numbers on a daily basis There are numbers, whole numbe natural numbers, etc. Another kind a numbers is called strange numbers, which the following properties :
A strange number is an integer number N’ which has factors that are prime numbers.

The square root of the number ‘N’ should be less than the greatest prime factor of ‘N’.

The task here is to find out if the given number ‘N’ is strange or Not Strange.

Example 1:

Input:

15- Value of N

Output: Strange

Explanation :

From the inputs given above N=15

The prime factors of N are 5,3

The greatest prime factor is 5

The square root of 15 is 3.87 and 3.87 < 5 (The greatest prime factor)

Hence the output is Strange.

Example 2:

Input:

25- Value of N

Output: Not Strange

Explanation :

From the inputs given above:
N = 25
The prime factor of N is 5.
The greatest prime factor is 5. Hence, the output is Not Sminge.
The square root of 25 is 5 which is not less than 5 the greatest prime factor of N

Hence the output is not Strange.

Constraints:

0<N<1000

The input format: The candidate has to write the code to accept 1 input

Output: Should be string check above example 1 and 2

TCS DCA Coding Questions Answers - 3:

Solution:

TCS DCA Coding Questions JAVA

//Solution by PrepInstaTechBlog

import java.util.*;
class PrepInstaTechBlog
{
public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
	int num=sc.nextInt();
    int a=0,b=0;
    for(int i=1;i<num;i++)
    {
	    if(num%i==0)
	    {
	        a=i;
	    }
	    if(b<a)
	    {
	        b=i;
	        a=0;
	    }
    }
    double root=Math.sqrt(num);
    if(b>root)
    {
        System.out.print("Strange");
    }
    else
    {
        System.out.print("Not Strange");
    }
}
}

TCS DCA Coding Questions Answers - 3:

Solution:

TCS DCA Coding Questions C++

// Solution by PrepInstaTechBlog


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long maxPrimeFactors(long long n)
{
    long long maxPrime = -1;
 
    
    while (n % 2 == 0) {
        maxPrime = 2;
        n >>= 1; 
    }
 
     while (n % 3 == 0) {
        maxPrime = 3;
        n=n/3;
    }
 

    for (int i = 5; i <= sqrt(n); i += 6) {
        while (n % i == 0) {
            maxPrime = i;
            n = n / i;
        }
      while (n % (i+2) == 0) {
            maxPrime = i+2;
            n = n / (i+2);
        }
    }
 
    
    if (n > 4)
        maxPrime = n;
 
    return maxPrime;
}
int main()
{
    int n;
    cin>>n;
    int sq=sqrt(n),p;
    
    p=maxPrimeFactors(n);
    if(p>sq)
        cout<<"Strange";
    else
        cout<<"Not Starnge";

    return 0;
}

TCS DCA Coding Questions Answers - 3:

Solution:

TCS DCA Coding Questions Python

#Solution by PrepInstaTechBlog

import math
def PrimeFactor(num):
    while num % 2 == 0:
        max_Prime = 2
        num /= 1
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        while num % i == 0:
            max_Prime = i
            num = num / i
    if num > 2:
        max_Prime = num
    return int(max_Prime)


num = int(input())
prime = PrimeFactor(num)
if prime > math.sqrt(num):
    print("Strange")
else:
    print("Not Strange")

TCS DCA Coding Questions 29th September 2021 - 4:

A chocolate distributor unit has installed two new automatic arms for the unloading of chocolate bars from containers. Arm A has the capacity to unload one chocolate bar, whilst the other arm B unloads two bars at
a time. In order for any two-containers to be unloaded fully and simultaneously by both arms, the distributor has to choose the correct chocolate bars quantity (quantity X for container unloaded by arm A and quantity Y for container unloaded by arm B) in those containers from the supplier.
The task is to develop a code to identify a pair of quantities (maximum quantity 5000) such that both the arms unload all chocolate bars from those containers fully and complete their unloading simultaneously, so the following containers can be placed for unloading automatically.

The correct pair identified can be marked as ‘Yes’ and the Incorrect pair as ‘No’.

Example 1:

Input:

100-Value of X

200-Value of Y

Output:

Yes - Prints Yes indicating 100 and 200 chocolate bars can be fully emptied simultaneously.

Example 2:

Input:

500-Value of X

900-Value of Y

Output:

No–Prints No indicating 500 and 900 chocolate bars cannot be fully emptied simultaneously

Explanation:

Arm A unloads 500 bars in 500 times and Arm B also unloads 900 bars in 450 times hence both the containers are not emptied at the same time and so, the next pair of containers cannot be automatically placed for unloading until arm A unloads another 50 bars.
Hence, the output is a ‘No’.

TCS DCA Coding Questions Answers - 4:

Solution:

TCS DCA Coding Questions JAVA

//Solution by PrepInstaTechBlog

import java.util.Scanner;
class Technoaname
{
public static void main(String[] args)
{
	Scanner sc= new Scanner(System.in);

	int a=sc.nextInt(); 
	int b=sc.nextInt();

	if(a*2==b)

	System.out.println("Yes");

	else

	System.out.println("No");
	}
}

TCS DCA Coding Questions Answers - 4:

Solution:

TCS DCA Coding Questions Python

# Solution by PrepInstaTechBlog

a=int(input())
b=int(input())
if a*2==b:
    print('Yes')
else:
    print('No')


Don't miss it! TCS DCA Exam Questions and Answers | TCS NQT to TCS Digital

 

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 29th 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 on our blog.


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.