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 27th September 2021
TCS DCA Coding Questions 28 September 2021
TCS DCA Coding Questions 28th September 2021 - 1:A man invests a certain amount on monthly basis in a bank. He withdraws that money once in 4 years which is a leap year, to make a big scale purchase .He starts next investment exactly 183 days after the purchase .
Initially, he makes a note of his purchase date
Given the date(dd) and month(mm) of his purchase. The task here is to help him find the date and month to start his investment.His next investment date is calculated from the next day of his purchase.
This question was asked in TCS DCA Exam 28th September 2021
Display the date as on 183rd day.
Example 1:
Input:
15–Value of dd
January-Value of mm
Output:
16 July- Date 183 days after his purchase
Constraints:
D<dd<=12
mm – {January to December}
Inputs
First input-Accept value for dd (positive integer number).
Second Input-Accept value for mm (month)
Output:
The output should be a positive integer number followed by the name of the month.
TCS DCA Coding Questions Answers - 1:
Solution:
TCS DCA Coding Questions Python
# Solution by prepinstatechblog.blogspot.com
def getDate(d, m):
days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
month = ['January', 'February',
'March', 'April',
'May', 'June',
'July', 'August',
'September', 'October',
'November', 'December']
cnt = 183
cur_month = month.index(m)
cur_date = d
while(1):
while(cnt > 0 and cur_date <= days[cur_month]):
cnt -= 1
cur_date += 1
if(cnt == 0):
break
cur_month = (cur_month + 1) % 12
cur_date = 1
print(cur_date, month[cur_month])
D = int(input())
M = input()
getDate(D, M)
TCS DCA Coding Questions Answers - 1:
Solution:
TCS DCA Coding Questions JAVA
//Solution by prepinstatechblog.blogspot.com
import java.util.Scanner;
class PrepInstaTechBlog
{
public static void getDate(int d, String m)
{
int[] days = { 31, 29, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
String[] month = { "January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December" };
int count = 183;
int current_month = 0;
for(int i = 0; i < 12; i++)
if (m == month[i])
current_month = i;
int current_date = d;
while (true)
{
while (count > 0 && current_date <= days[current_month])
{
count -= 1;
current_date += 1;
}
if (count == 0)
break;
current_month = (current_month + 1) % 12;
current_date = 1;
}
System.out.println(current_date + " " +month[current_month]);
}
public static void main(String args[])
{
int D;
String M;
Scanner sc=new Scanner(System.in);
D=sc.nextInt();
M=sc.next();
getDate(D, M);
}
}
TCS DCA Coding Questions Answers - 1:
Solution:
TCS DCA Coding Questions C++
//Solution by prepinstatechblog.blogspot.com
#include <iostream>
using namespace std;
void getDate(int d, string m)
{
int days[] = {31, 29, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
string month[] = {“January”, “February”, “March”,
“April”, “May”, “June”, “July”,
“August”, “September”, “October”,
“November”, “December”};
int count = 183;
int current_month = 0;
for (int i = 0; i 0 && current_date <= days[current_month])
{
count -= 1;
current_date += 1;
}
if (count == 0)
break;
current_month = (current_month + 1) % 12;
current_date = 1;
}
cout << current_date << " " <> D;
cin >> M;
getDate(D, M);
return 0;
}
TCS DCA Coding Questions 28th September 2021 - 2:
There are ‘N’ number of companies participating in the drive. The commencement timings of the interviews of ‘N’ companies is given as start[] array elements and their respective end timings are given as end[] array elements. The task here is to find the maximum number of interviews a single candidate can attend keeping the following points in mind:
All the interview timings are in ‘p.m’.
• The candidate cannot attend an interview if its timings overlap with the timings of another company’s interview. Say, an interview starts at 1 p.m. and ends at 4 p.m., he cannot attend the interview of another company between 1 p.m. to 4 p.m.
Only one candidate can be scheduled in the given time slot
Assume, the input for end time(end[]) is always sorted in ascending order.
Example
Input
66- Value of N
(2,4,1,6,9,6)-start[], Elements start[0] to start[N-1],
where each input element is separated by a new line
(3,5,7,8,10,10)-end[], Elements end[0] to end[N-1], where each input element is separated by a new line
Output
4
TCS DCA Coding Questions Answers - 2:
Solution:
TCS DCA Coding Questions JAVA
//Solution by prepinstatechblog.blogspot.com
import java.util.Scanner;
class PrepInstaTechBlog
{
public static void main(String args[])
{
Scanner Sc=new Scanner(System.in);
int size=Sc.nextInt();
int[] starttime=new int[size];
int[] endtime=new int[size];
for(int i=0;i<size;i++)
{
starttime[i]=Sc.nextInt();
}
for(int j=0;j<size;j++)
{
endtime[j]=Sc.nextInt();
}
int count=1;
int result=endtime[0];
for(int k=0;k<size-1;k++)
{
if(result<=starttime[k+1])
{
result=endtime[k+1];
count++;
}
}
System.out.println(count);
}
}
The above question is solved in Java, if you have the solution in another language then write it in the comment box.
TCS DCA Coding Questions September 2021 - 3:
A faulty program stores values from the username and password fields as a continuous sequence of characters. When trying to fetch either the username or password, the entire string is displayed Given the string str, the task here is to find and extract only the letters and special characters from the whole string stored.
Note:
The letters and special characters should be displayed separately.
The output should consist of all the letters, followed by all the special characters present in the input string.
Example 1 :
Input:
name@1234password — Value of str
Output: namepassword@–only letters and special characters
Explanation:
From the inputs given above string name@1234password, Extracting only letters and special characters
Constraints:
Str = {A-Z, a-z, 0-9. special characters}
Input:
The candidate has to write the code to accept 1 input • First Input – Accept value for str (String)
Output
The output should be only letters and special characters from the input string (check the output in Example 1 )
• Additional messages in the output will cause the failure of test cases. 299101 2991016
Instructions:
The system does not allow any kind of hardcoded input value/values
TCS DCA Coding Questions Answers - 3:
Solution:
TCS DCA Coding Questions JAVA
//Solution by PrepInstaTechBlog
import java.util.Scanner;
public class PrepInstaTechBlog
{
static String Result(String s)
{
String alphabets="",specialCharacter="";
for(int i=0;i<s.length();i++)
{
if((s.charAt(i)>='A'&& s.charAt(i)<='Z') || (s.charAt(i)>='a'&& s.charAt(i)<='z'))
{
alphabets+=s.charAt(i);
}
else if(!(s.charAt(i)>='0'&& s.charAt(i)<='9'))
{
specialCharacter+=s.charAt(i);
}
}
return alphabets+specialCharacter;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
System.out.println(Result(s));
}
}
TCS DCA Coding Questions September 2021 - 4:
Kids up to the age of 7 are confused formation of letters and numbers, teacher uses the different methodologies to make the concepts of mathematics clear to the students. One of the methods the teacher uses to emphasis on the addition and recognition of numbers is that she muddles up the numbers randomly and then asks the students to find difference between adjacent digits. The task here to find given number is CORRECT or INCORRECT.
• A number is correct if the between the adjacent (right and left) digits is 1.
• The number can be positive or a negative
Example :
7876— Value of N
Output: CORRECT
Explanation:
the inputs given above:
N = 7876
Difference between the digits
7-8=-1
8-7=1
7-6 = 1
6-7 = -1
The maximum difference between all adjacent digits is 1, hence output is CORRECT.
TCS DCA Coding Questions Answers - 4:
Solution:
TCS DCA Coding Questions C Language
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int number;
cin>>number;
number=abs(number);
int remainder1=number%10;
number=number/10;
while(number>0)
{
int remainder2=number%10;
if(abs(remainder1-remainder2)==1)
{ remainder1=remainder2;
number=number/10;
}
else
break;
}
if(number>0)
cout<<"INCORRECT";
else
cout<<"CORRECT";
return 0;
}
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 28th 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: