# TCS Digital Capability Assessment Questions: 29 Sept 2021

This section covers the TCS DCA (Digital capability questions) that were asked on 29th September 2021 in the morning slot at 11 am.

Please click here to find out the TCS Digital Capability Assessment questions asked on 29th September 2021 in the evening slot at 4 pm.

This is the third time when TCS Elevate Wings DCA is conducting the year 2021. Earlier it is organized in the month of January and April.

Eligibility

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

Assessment Date: 27th to 30th Sep

Click here to find out the coding questions asked in TCS Digital Capability Assessment on 27th September 2021.

Click here to find out the coding questions asked in TCS Digital Capability Assessment on 28th September 2021.

Below were the coding questions asked on 29th September 2021 in the morning slot at 11 am.

Question 1 :

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 for testing: The candidate has to write the code to accept 1 input

Output: Should be string check above example 1 and 2

## Solution in Java

``````//Solution by Technoname.com

import java.util.*;
class Technoname
{
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");
}
}
}``````

## Solution in C++

``````// Solution by technoname.com

#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;
}
``````

## Solution in Python

``````#Solution by technoname.com

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")``````

Question 2 :

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’.

Solution in Java:

``````//Solution by Technoname.com

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");
}
}``````

Solution in Python :

``````# Solution by technoname.com

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

Question numbers 1 and 2 were asked in the morning slot at 11 AM.

You can also check some other coding questions that were asked in the previous DCA (Digital capability Assessment) from here.

Please check most asked programming questions of strings with examples by clicking here, after that you might get a deep knowledge about string operations, in short, it will be helpful in clearing the interview

### 20 responses to “TCS Digital Capability Assessment Questions: 29 Sept 2021”

1. a says:

thanks a lot for posting

2. coder_45 says:

Python 3:

For first Question:

#code by coder_45

def strange_not(x):
l= [i for i in range(1,x) if (x % i) == 0]
sq = round(pow(x,1/2),2)

if max(l) > sq:
print(‘Strange’)
else:
print(‘Not Strange’)

x = 28

strange_not(x)

3. Ashish says:

Hye, Akshat
In 1st question, you have not checked 1st condition of the question that all the factors must be prime numbers only. So, I think, for each factor you have to also check if they are prime number or not.
Eg. num = 18
factors apart from 1 & 18 = 2,3,6,9
According to your solution, the output will be “Strange” but it should be “Not Strange” because factors 6 and 9 are composite numbers i.e. 1st condition becomes false.

• Akshat Jain says:

Okay Will check and update, if you have a solution then please share it with us.

4. Venkatesh Kondaru says:

package com.primeFactors;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class MyClass {

public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
List factors=new ArrayList();
List primeFactors=new ArrayList();
boolean exit=true;
for(int i=2;i<num;i++) {
if(num%i==0) {
}
}
int factor;
for(int j=0;j<factors.size();j++) {
int count=0;
factor=factors.get(j);
for(int i=1;iMath.sqrt(num)){
System.out.println(“Strange”);
} else {
System.out.println(“No Strange”);
}
}
}
}

5. Venkatesh Kondaru says:

import java.util.ArrayList;import java.util.List;import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
List factors=new ArrayList();
List primeFactors=new ArrayList();
boolean exit=true;
for(int i=2;i<num;i++) {
}
int factor;
for(int j=0;j<factors.size();j++) {
int count=0;
factor=factors.get(j);
for(int i=1;iMath.sqrt(num)){System.out.println(“Strange”);} else {
System.out.println(“No Strange”);}}}}

6. Venkatesh Kondaru says:

Please ignore this. Some part of code was not pasted while ctl+c and ctrl v due to limit of line in comment box.

7. Venkatesh Kondaru says:

Please dont refer 1st comment. Refer 2 comment that contain code.

8. Venkatesh Kondaru says:

For First Question :
Check below. Tested for numbers: 2,3,4,5,6,7,8,11,12,13,15,21. Please share your comments. if this code fails for any test case.
import java.util.ArrayList;import java.util.List;import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
List factors=new ArrayList();
List primeFactors=new ArrayList();
boolean exit=true;
for(int i=2;iSystem.out.print(i+”,”));
for(int j=0;j<factors.size();j++) {
int count=0;
factor=factors.get(j);
for(int i=1;iSystem.out.print(i+”,”));
double sqrt=(double) Math.sqrt(num);
System.out.println(“Highest prime factor is:”+primeFactors.get(primeFactors.size()-1)+” and sqrt of num is: “+sqrt);
if(primeFactors.get(primeFactors.size()-1)>sqrt)
System.out.println(“Strange”);
else
System.out.println(“No Strange”);}}}

9. Venkatesh Kondaru says:

Please Check this code. This will work. Tested for nums: 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,21.
package com.primeFactors;import java.util.ArrayList;import java.util.List;import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {Scanner sc=new Scanner(System.in);int num=sc.nextInt();List factors=new ArrayList();List primeFactors=new ArrayList();boolean exit=true;for(int i=2;iSystem.out.print(i+”,”));for(int j=0;j<factors.size();j++) {int count=0;factor=factors.get(j);for(int i=1;iSystem.out.print(i+”,”));
double sqrt=(double) Math.sqrt(num);
System.out.println(“Highest prime factor is:”+primeFactors.get(primeFactors.size()-1)+” and sqrt of num is: “+sqrt);if(primeFactors.get(primeFactors.size()-1)>sqrt)System.out.println(“Strange”);
else System.out.println(“No Strange”);}}}

10. Venkatesh says:

package com.primeFactors;
/*Please Check this code. This will work. Tested for nums: 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,21.
Please share comment if any testcase fails.*/
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class MyClass {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
List factors = new ArrayList();
List primeFactors = new ArrayList();
boolean exit = true;
for (int i = 2; i System.out.print(i + “,”));

11. Venkatesh says:

for (int j = 0; j < factors.size(); j++) {
int count = 0;
factor = factors.get(j);
for (int i = 1; i <= factor; i++) {
if (factor % i == 0) {
count++;
}
}
if (count == 2)
else {
if (factor != num) {
System.out.println();
System.out.println("No Strange");
exit = false;
break;
}
}
}

12. Venkatesh says:

if (exit) {
System.out.println();
System.out.print(“PrimeFactors of number :” + num + ” are :”);
primeFactors.forEach(i -> System.out.print(i + “,”));
double sqrt = (double) Math.sqrt(num);
System.out.println(“Highest prime factor is:” + primeFactors.get(primeFactors.size() – 1)
+ ” and sqrt of num is: ” + sqrt);
if (primeFactors.get(primeFactors.size() – 1) > sqrt)
System.out.println(“Strange”);
else
System.out.println(“No Strange”);
}
}
}
/*************** END ***********************/

13. Hrudini says:

solution in C for first question

#include
#include
#include
int main ()
{
int n,s,i,pf;
//float s;
scanf(“%d”,&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
pf=i;
}

}
s=sqrt(n);
if(s==pf)
{
printf("Not Strange");
}
else
{
printf("Strange");
}

return 0;
}

14. Hrudini says:

solution for second question in C

#include
#include
#include
int main ()
{
int n,m;
scanf(“%d %d”,&n,&m);

if(m==2*n)
{
printf(“Yes”);
}
else
{
printf(“No”);
}

return 0;
}