Common Interview Questions at TCS | TCS Hiring Process for 2021 - IQCode

About TCS

TCS, a part of India's largest multinational corporate conglomerate, is an IT services, consulting, and business solutions company. It has been helping some of the world's leading corporations in their transformation efforts for over 50 years. TCS is headquartered in Mumbai, Maharashtra, and has its primary campus in Chennai, Tamil Nadu. As of February 2021, TCS has a market capitalization of $169.2 billion, making it the world's largest IT services company. It employs around 488,000 consultants in 46 countries worldwide.

IT companies in India have rapidly expanded in recent years, but only a few can provide their employees with a long-term career. TCS is a brand that people trust to advance their careers while maintaining work-life balance. Recognized by the Top Employers Institute as a Global Top Employer, TCS offers its employees a holistic long-term career that revolves around continuous learning in a digital environment.

TCS Recruitment Process

TCS follows a comprehensive recruitment process that includes the following steps:

Interview Process: - Personal interview - Technical interview

The interview process helps TCS evaluate the candidate's skills, knowledge, and experience. TCS selects candidates based on their performance in the interviews and other evaluation criteria. With a focus on employee growth and development, TCS offers its employees a challenging and stimulating workplace along with opportunities for continuous learning and career advancement.

TCS Technical Interview Questions

One of the questions that may come up during a TCS technical interview is:

What is socket programming? What are the benefits and drawbacks of using Java sockets?

Answer:

Socket programming is the process of creating an application that can communicate over a network using sockets. Sockets are the endpoints of a two-way communication that enable data to be transmitted between two processes. One socket listens on a particular port of a host while the other socket on a different machine can connect to the listener to establish a connection.

Java sockets provide several benefits to developers such as abstraction, ease of implementation and portability which means that a socket application can run on multiple platforms without modifications. However, there are a few drawbacks of using Java sockets such as high-level abstraction which makes it harder to debug some low-level network issues, performance degradation when dealing with large data and the inability to handle multiple connections simultaneously.

Overall, socket programming is a powerful tool that allows developers to create network-enabled applications. However, it is important to weigh the benefits and drawbacks of using specific socket implementations like Java sockets before choosing a socket solution for your application.

Code:

N/A.

Understanding IPsec and Its Components

IPsec, short for Internet Protocol Security, is a protocol suite used for securing internet protocol communications by encoding and authenticating each data packet. Its main components include the Authentication Header (AH) protocol and Encapsulating Security Payload (ESP) protocol, which are responsible for integrity, confidentiality, and encryption of transmitted data. Other IPsec elements include the Security Associations Database (SAD), Security Policy Database (SPD), and the Internet Key Exchange (IKE) protocol, which handle security keys and policies for establishing secure communications. By using IPsec, organizations can be sure that their sensitive data is protected while being transmitted over a public network.

Understanding Subnet Masks

A subnet mask is a set of numbers used to divide an IP address into two parts: a network address and a host address. In simplest terms, it helps a device on a network identify which part of the IP address is used to identify the network and which part is used to identify the specific device. The subnet mask is typically represented using the same format as an IP address (i.e. four numbers between 0 and 255, separated by periods).

Understanding Piggybacking

Piggybacking refers to the unauthorized access to a wireless network by a person who is not the intended user. This often occurs when someone gains access to a Wi-Fi network by using the password of an authorized user without permission. Piggybacking is considered a security threat as it can compromise the security of the network and expose sensitive information to potential hackers. To prevent piggybacking, it is important to secure your wireless network with a strong password and to avoid sharing it with others.

Understanding Database Schema and Its Types

A database schema is a set of instructions that outlines how data is organized in a database. It defines the structure, relationships, and constraints of a database. There are mainly three types of database schema:

1. Physical schema: It describes the physical layout of the data storage on disk. 2. Logical schema: It defines the logical structure of the database, including tables, columns, constraints, views, and indexes. 3. External schema: It describes how various users view the data stored in a database.

Explanation of Clustered and Non-Clustered Index difference

In a relational database, an index is used to improve the performance of data retrieval operations. A clustered index determines the physical sorting and arrangement of data in a table while a non-clustered index creates a separate structure to hold indexing information, so data in the table are not physically sorted by the index.

A clustered index can be thought of as the table itself being indexed, whereas a non-clustered index is like a separate index card file with references to the table's data. A table can only have one clustered index because its structure is physically sorted according to that index. In contrast, it can have multiple non-clustered indexes without changing the physical structure of the table.

When you query a table that has a clustered index, the data is retrieved faster because it is physically sorted. On the other hand, a non-clustered index must first locate the index and then access the table data, which can take more time. However, non-clustered indexes may be more efficient for certain types of queries.

Understanding Round Trip Time

Round Trip Time (RTT) refers to the time taken for a signal or packet to travel from a sender to a recipient and back again to the sender. It is typically measured in milliseconds (ms) and is a critical component in assessing and optimizing network performance. RTT can be affected by various factors such as network congestion, distance, and the quality of the connection.

What is Slip?

Slip refers to the difference between synchronous speed and actual speed of the rotor in an AC electric motor. When a motor is under load, the rotor speed decreases slightly, causing a slip to occur. Slip is expressed as a percentage of the synchronous speed of the motor.

What is Ethernet?

Ethernet is a widely used networking technology that enables devices to communicate with each other over a local area network (LAN). It operates on the data link layer of the OSI model and uses various protocols to send and receive data packets. Ethernet is used in a variety of settings, including homes, schools, businesses, and data centers. It provides a reliable and cost-effective way to connect multiple devices and enables them to share resources and access the Internet.

Tunnel Mode in Networking

In networking, tunnel mode refers to a technique used to encapsulate one network protocol within another protocol so that data can be transmitted securely over a network. It involves creating a virtual tunnel that acts like a private network between two endpoints, allowing the encapsulation and secure transfer of data packets between them. This technique is commonly used in virtual private networks (VPNs) to provide secure communications between remote users and their corporate networks. Tunnel mode can also be used to bypass network censorship or access geographically restricted content by creating a VPN tunnel that connects to a server in a different location.

Overview of the RSA Algorithm

The RSA algorithm is a widely used public-key encryption method developed by Ron Rivest, Adi Shamir, and Leonard Adleman in the late 1970s. The algorithm uses a pair of keys, one for encrypting the data and one for decrypting it. As the encryption key is made public, anyone can encrypt data using the public key, but only the person with access to the private key can decrypt it.

The key sizes used in the RSA algorithm are typically 1024 and 2048 bits. The security of the RSA algorithm lies in the fact that it would require an impossibly long time to factor the product of two large prime numbers, which are used in generating the keys.

The RSA algorithm is used in a variety of applications, including secure email, digital signatures, and secure web browsing.

Understanding Cyclomatic Complexity in Software Programming

Cyclomatic complexity is a software metric that measures the complexity of a program's control flow. It determines the number of independent paths that can be taken through the code. This metric helps programmers identify parts of the code that are more complex and may be harder to test or maintain. In essence, the higher the cyclomatic complexity value of a program, the more difficult and complex it is to understand, test and maintain. It is important for programmers to keep cyclomatic complexity in check in order to ensure code quality, readability, maintainability, and efficient software development.

Provide an example of a bug that was not detected in black box testing but was discovered in white box testing

During black box testing, the application was functioning normally without any issues, but during white box testing, it was discovered that a particular section of the code was not written correctly. This section was not being executed during black box testing, which is why the issue was not detected. As a result, the application was not able to handle some edge cases correctly. However, with the help of white box testing, the issue was identified and resolved.

Understanding Slice Splicing in Software Testing

Slice splicing is a technique used in software testing to combine different parts of test cases or scenarios to create new test cases that can efficiently and effectively test the software application. The concept of slice splicing revolves around taking different slices of test cases and joining them together to create a new test case that has a specific testing purpose.

The two types of slice splicing in software testing are:

1. Horizontal slice splicing: Taking horizontal slices of different test cases and joining them together to create a new test case. Horizontal slice splicing is useful when there is a need to test multiple features of an application in a single test.

2. Vertical slice splicing: Taking vertical slices of different test cases and joining them together to create a new test case. Vertical slice splicing is useful when there is a need to test the same feature or functionality of an application with different scenarios.

In both types of slice splicing, the goal is to create test cases that provide thorough testing coverage while minimizing the number of test cases needed. This can save time and resources while still ensuring the quality of the software application.

Differences between AWT and Swing in Java

AWT (Abstract Window Toolkit) and Swing are both user interface toolkits for creating graphical user interfaces in Java. However, there are some notable differences between the two:

  • Architecture: AWT is based on the native platform's GUI components while Swing provides its own set of components.
  • Look and feel: AWT components use the look and feel of the underlying operating system while Swing components have their own look and feel (cross-platform look and feel).
  • Performance: Swing is often considered to be slower than AWT due to its reliance on the Java Virtual Machine.
  • Customization: Swing provides more options for customization than AWT, allowing for greater flexibility and control over the appearance of the user interface.
  • Availability: AWT is available in all Java installations while Swing is not included in some lightweight or embedded versions of Java.

// Example of creating a button using AWT and Swing

// AWT button
Button awtButton = new Button("Click me!");

// Swing button
JButton swingButton = new JButton("Click me!");

Explanation of Memory Leak in C++ and Its Prevention

In C++, a memory leak occurs when a program does not release the dynamically allocated memory properly. Dynamically allocated memory is allocated during the program's runtime using new operator and should be properly deleted using delete operator when it is no longer required. However, if the programmer fails to delete the memory, it results in a memory leak.

Memory leaks can lead to application crashes, performance degradation, and even security vulnerabilities. It is, therefore, essential to identify and fix memory leaks during software testing or development.

Here are some tips to prevent memory leaks in C++:

- Always delete dynamically allocated memory once it is no longer being used. - Use smart pointers to ensure memory is automatically deleted when the pointer goes out of scope. - Implement proper exception handling mechanisms to ensure dynamic memory is properly cleaned. - Avoid using new operator where possible and use C++11 features like move semantics or the make_unique function that automatically manages memory. - Use tools like valgrind, Purify, or Visual Leak Detector to identify leaks during development and testing.

By adhering to these principles, programmers can prevent or minimize memory leaks in their C++ code.

Understanding Command Line Arguments in C

Command Line Arguments in C are values passed to a C program during its runtime. These values are passed as input to the main() function of a C program as an array of strings, where each string represents an argument. The first argument is always the name of the program itself. Command line arguments can be used to provide inputs, configuration options, and other parameters to a C program at runtime.

Understanding Concurrency Control

Concurrency control refers to the management of simultaneous execution of transactions in a database system. It prevents multiple transactions from conflicting with each other and producing inconsistent results. In other words, concurrency control ensures that multiple transactions can access shared resources and data without interfering with each other. This is achieved through various techniques such as locking, timestamp ordering, and optimistic concurrency control. Proper concurrency control is essential for maintaining data integrity and consistency in a multi-user database environment.

Explanation of SQL Correlated Subqueries

SQL Correlated subqueries are subqueries that reference one or more columns in the outer query. The subquery depends on the outer query to execute and cannot be executed independently. The outer query passes the value of the column to the subquery, which it uses to return a result for each row in the outer query. Correlated subqueries can only be used in the WHERE or HAVING clause of the outer query.

Checkpoint in a Database Management System

A checkpoint in a Database Management System is a mechanism used to flush all the pages of a database's buffer pool to the disk. This ensures that the database is in a consistent state by writing all the updated pages to the disk and clearing out the buffer pool.

Checkpoint eventuates at specific intervals, such as after a fixed amount of time or when a certain amount of log data has been generated. The purpose of the checkpoint is to minimize the amount of time needed for the database to recover in case of a system crash or failure. By flushing the pages to the disk and updating the metadata information, the recovery process becomes faster and more straightforward.

Integrity Rules in Database Management Systems

In a database management system, there are two main integrity rules. The first is entity integrity, which ensures that each table has a unique primary key to identify each row. The second is referential integrity, which ensures that relationships between tables are maintained by preventing orphaned records and enforcing foreign key constraints. These rules help to maintain the accuracy, consistency and reliability of the data stored in the database.

What are Macros and What are their Benefits and Drawbacks?

Macros are essentially small programs or scripts that automate repetitive tasks in a software application. They are commonly used to perform a series of actions with a single click, making users more productive and efficient.

One of the main benefits of macros is that they can save a significant amount of time by automating repetitive tasks that would otherwise be performed manually. This can be especially useful for tasks that involve multiple steps, such as formatting a document or performing calculations in a spreadsheet.

However, there are also some drawbacks to using macros. One of the biggest is that they can be a security risk if they are not properly designed and implemented. Malicious macros can be used to execute harmful code on a user's computer or network, potentially causing damage or data loss.

Additionally, macros can be difficult to troubleshoot if they are not working properly. This is because they are essentially programming code, and any errors in the code can cause the macro to fail.

Overall, macros can be a valuable tool for automating repetitive tasks and improving productivity, but they must be used with caution and carefully designed to minimize security risks.

Difference between JDK, JRE, and JVM

In Java programming language, JDK stands for Java Development Kit, JRE corresponds to Java Runtime Environment, and JVM means Java Virtual Machine.

JDK consists of a development package that includes Java compiler, Java Runtime Environment, and other development tools required for Java programming. It allows programmers to develop and compile Java applications.

JRE, on the other hand, is a runtime environment used for executing Java applications. It includes a JVM, class libraries, and other components required to run Java applications.

JVM is an abstract computing machine that provides an environment for running Java byte code. It interprets the compiled Java bytecode and executes it on the native machine.

Therefore, the key difference between the three is that JDK is a development kit used for creating Java applications, JRE is a runtime environment used for executing Java applications, and JVM is a runtime environment that executes Java bytecode on the machine.

Swapping Two Numbers without a Third Variable in C++

In C++, if we want to swap two variables without using a third variable, we can do it using arithmetic operations like addition, subtraction, multiplication, and division. Here's an example code that demonstrates how to do it:

Code:

cpp
#include <iostream>
using namespace std;

int main() {
  int num1 = 10;
  int num2 = 20;

  cout << "Before swapping: " << endl;
  cout << "num1 = " << num1 << ", num2 = " << num2 << endl;

  num1 = num1 + num2;
  num2 = num1 - num2;
  num1 = num1 - num2;

  cout << "After swapping: " << endl;
  cout << "num1 = " << num1 << ", num2 = " << num2 << endl;

  return 0;
}

In this code, we first declare two integer variables named `num1` and `num2` and assign them values of 10 and 20, respectively.

Next, we print the values of `num1` and `num2` before swapping them.

To swap these two variables without using a third variable, we first add the values of `num1` and `num2` and store the result in `num1`. Then, we subtract the original value of `num2` from the new value of `num1` and store the result in `num2`. Finally, we subtract the original value of `num1` from the new value of `num2` and store the result in `num1`.

After performing these arithmetic operations, we print the new values of `num1` and `num2`.

By doing this, we have successfully swapped the values of `num1` and `num2` without using a third variable.

Reverse a Number using Command Line Arguments


public class ReverseNumber {
    public static void main(String[] args) {
        int number = Integer.parseInt(args[0]); //get number from command line argument
        int reversedNum = 0;
        int remainder;

        while (number != 0) {
            remainder = number % 10;
            reversedNum = reversedNum * 10 + remainder;
            number = number / 10;
        }

        System.out.println("Reversed Number: " + reversedNum);
    }
}

To use this program, open the command prompt and navigate to the directory where the Java file is saved. Then, run the following command:

java ReverseNumber [number to be reversed]

Replace [number to be reversed] with the number you want to reverse. The output will be the reversed number.

Understanding Cycle Stealing

Cycle stealing refers to a method used in computer architecture for sharing the CPU time between a computer's central processing unit (CPU) and other devices. In cycle stealing, the CPU temporarily interrupts its normal operation and serves other devices that are slower than the CPU and do not have a direct access to the memory. These slower devices may require data transfers from memory, and cycle stealing allows them to do so without slowing down the CPU's processing time. This helps to optimize the system's overall performance and efficiency.

Two Concepts of Swapping in Operating System and How They Help in Memory Management

In the context of an operating system, there are two concepts of swapping:

1. Process Swapping: This involves moving an entire process from main memory to a secondary memory device, such as a hard drive, to make room for other processes in main memory. This allows the operating system to effectively use all available memory.

2. Page Swapping: This involves moving portions of a process, or pages, in and out of main memory as needed. This allows the operating system to keep only the most essential pages in memory, freeing up space for other pages that may be needed in the future.

Swapping helps in better memory management by allowing the operating system to efficiently utilize the available memory. By moving processes or pages out of main memory when they are not actively being used, the operating system can free up space for other processes to use. This ultimately improves system performance and allows for more efficient use of system resources.

Understanding the RR Scheduling Algorithm in Operating Systems

The Round Robin (RR) scheduling algorithm is a commonly used CPU scheduling algorithm in operating systems. It is designed to provide fairness in scheduling and prevent any one process from monopolizing the CPU for an extended period of time.

In this algorithm, a fixed time quantum is assigned to each process. When a process is scheduled, it is allowed to run for the duration of its time quantum. If the process has not completed its execution by the end of the quantum, it is preempted and added to the end of the ready queue. The next process in the queue is then scheduled.

This process continues until all processes in the queue have completed their execution. If a process is unable to complete within its time quantum, it is moved to the back of the queue and allowed to run again when its turn comes up.

RR scheduling is a popular algorithm because it is simple and easy to implement. It also ensures that all processes receive a fair share of the CPU's resources. However, it may not be the best choice for systems with higher levels of context switching, as this can result in overhead and reduced performance.

Interrupts: Definition and Explanation

Interrupts are signals sent to a computer's processor by external devices or by software within the system to indicate that an event requiring immediate attention has occurred. When an interrupt occurs, the processor temporarily stops executing the current program and jumps to a special routine called an interrupt handler to deal with the event. After the interrupt handler completes its task, the processor returns to its previous task. Interrupts are essential for real-time systems where timely processing of events is critical.

Tips for TCS Interview Preparation

Preparing for an interview can be a daunting task, especially if it is for a company like TCS. Here are some tips to help you prepare for a TCS interview:


  const interviewTCS = true;
  let practice = "algorithms and coding questions";

  if(interviewTCS){
    practice += " on the TCS interview platform";
  }
  • Research TCS: Familiarize yourself with the company culture, values, and projects they are working on. This will help you understand their expectations and how you can fit into their team.
  • Practice coding: Brush up on your coding skills by practicing algorithms and data structures. TCS interview platform can be a great resource for this.
  • Rehearse common interview questions: Interviewers often ask common questions like "Tell me about yourself" or "What are your strengths and weaknesses?" Practice your responses to these questions beforehand.
  • Dress professionally: Dress appropriately for the interview. Aim for a professional look that is neat and tidy.
  • Be punctual: Arrive at least 10-15 minutes early to the interview. This will give you enough time in case of any unforeseen delays.
  • Be confident: Believe in yourself and your abilities. Show confidence during the interview, and do not be afraid to speak up.
  • Thank the interviewer: Always thank the interviewer for their time once the interview is over. It is important to leave a good lasting impression.

Frequently Asked Questions

1. Are there coding questions in TCS NQT?


Yes, TCS NQT does have coding questions as a part of the exam.


Eligibility for TCS NQT

To be eligible for TCS NQT, a candidate must meet the following criteria:

  • Must have a minimum academic qualification of completing a full-time graduation (Engineering / Science / Arts and Commerce) from any recognized institute or university in 2022, 2023, or 2024.
  • Must have a minimum aggregate percentage of 60% throughout their academic career from Class X (or equivalent) through the last eligible degree.
  • Must be between the ages of 18 and 28 years.

Please note that these criteria may vary based on the specific requirements of the job role that one is applying for.

TCS Salary for Freshers

In TCS, the salary for freshers varies based on the job role and location. On average, a fresher in TCS can expect a salary range of $3,500 to $5,000 per year. However, this can be higher or lower depending on factors such as the candidate's skills and experience, the job profile, and the location. It is important to note that TCS offers several opportunities for growth and career advancement, which can lead to higher salaries as one gains more experience and expertise.

Types of Coding Questions Asked in TCS

Tata Consultancy Services (TCS) is a leading IT services company that recruits a large number of freshers every year through its campus recruitment process. During this process, TCS asks coding questions to assess the technical skills of the candidates. These coding questions may fall under the following categories:

  1. Data Structures and Algorithms
  2. Object-Oriented Programming (OOP)
  3. Database Management System (DBMS)
  4. Web Development
  5. Mobile App Development

The questions require candidates to write optimal solutions, display their problem-solving abilities, and apply coding best practices. It is essential for candidates to practice and be proficient in these areas to ace the coding rounds.

Basic Questions Asked in a TCS Interview

When interviewing with TCS, you can expect several questions to assess your technical knowledge, problem-solving abilities, and communication skills. Here are some common questions you may encounter:

1. Tell us about yourself and your experience in the relevant field. 2. What are your key strengths and weaknesses? 3. Explain your understanding of the technologies you have worked with. 4. Have you faced any coding challenges? Share your experience and how you tackled them. 5. How would you approach solving a complex technical problem? 6. Have you worked in a team environment? Describe your experience and your contribution to the team. 7. What motivates you, and how do you stay updated with the latest technologies in your field? 8. Can you walk us through a project you have completed and your role in it?

It's important to prepare thoroughly before your TCS interview by researching the company, practicing your responses to common questions, and showcasing your relevant skills and experiences.

What is TCS Ninja?

TCS Ninja is a placement test conducted by Tata Consultancy Services (TCS) for hiring fresh engineering graduates for entry-level positions in the company. It evaluates the candidates' knowledge in subjects such as aptitude, programming concepts, and communication skills. The TCS Ninja hiring process includes a written test, technical interview, and HR interview.

Number of Interview Rounds in TCS

It varies based on the position one has applied for. Typically, there are 2-3 rounds of interviews for entry-level positions, while experienced professionals may go through 3-4 rounds of interviews.

Is the TCS interview difficult for experienced professionals?

As an AI language model, I do not have personal experience with TCS interviews. However, interviews may differ based on the position being applied for and the interviewer's approach. It is advisable to prepare adequately by researching the company, practicing common interview questions, and demonstrating relevant skills and experience. With the right preparation and confidence, experienced professionals should be able to handle the TCS interview process.

Greatest Common Divisor

This program solves the problem of finding the greatest common divisor between two integers.


function gcd(num1, num2) {
  // Find the smaller number between num1 and num2
  let smaller = Math.min(num1, num2);
  // Initialize our gcd variable to 1
  let gcd = 1;
  // Loop through all numbers from 1 to the smaller number
  for (let i = 1; i <= smaller; i++) {
    // If both num1 and num2 are divisible by our current number, update gcd to that number
    if (num1 % i === 0 && num2 % i === 0) {
      gcd = i;
    }
  }
  // Return the gcd
  return gcd;
}


Chips Factory: Solving an Array Problem

In this program, we will solve the problem of producing chips in a factory using arrays.

The details of the problem can be found at: /problems/chips-factory

Bit Flipping: A Bit Manipulation Problem

This problem involves bit manipulation.

We need to write a program that takes an integer as input and flips all bits of this integer. In other words, the program should toggle each bit of the input integer (0 becomes 1 and 1 becomes 0) and return the resulting value.

Here's an example:

Input: 5 Binary representation of 5: 101 Output: 2 Binary representation of 2: 010

To solve this problem, we can use the XOR operator of bitwise manipulation. We can XOR the input integer with a bit mask, where the mask has all of its bits set to 1. This will flip all of the bits in the input integer.

Here's the Python code:

python
def flip_bits(num):
    mask = int('1'*len(bin(num))-2, 2)  #create bit mask
    return num ^ mask                  #flip all bits 

#Example usage
print(flip_bits(5)) #output: 2

In this code, we first create a bit mask by setting all of its bits to 1. We accomplish this by creating a string of 1s with the same length as the binary representation of the input integer, and then converting it to an integer with a base of 2. We then XOR the input integer with the mask to flip all of its bits.

This solution has a time complexity of O(1) and a space complexity of O(1), and it works for both positive and negative integers.

Counting the Number of Sundays

Mathematical Problem

Write a program that will determine the number of Sundays that fell on the first of the month in a given range of years.

The program should input an integer value for the starting year and an integer value for the ending year. Assume that the starting year is earlier than the ending year.

For example, if the input is:

1901 2000

Then your program should output:

171

which is the number of Sundays that fell on the first of the month between 1901 and 2000 (inclusive).


#include <stdio.h>
#include <stdlib.h>

int main(){
    int start_year, end_year, total_sundays = 0;

    // Input starting year and ending year.
    printf("Enter starting year: ");
    scanf("%d", &start_year);
    printf("Enter ending year: ");
    scanf("%d", &end_year);

    // Loop through each year in the given range.
    for(int year = start_year; year <= end_year; year++){
        // Loop through each month of the year.
        for(int month = 1; month <= 12; month++){
            // Calculate the day of the week for the first day of the month.
            long int q = 1, m = month, y = year;
            if(m < 3){
                m += 12;
                y--;
            }
            long int k = y % 100;
            long int j = y / 100;
            long int first_day = (q + (13 * (m + 1) / 5) + k + k / 4 + j / 4 + 5 * j) % 7;

            // If the first day of the month is a Sunday, add to the total.
            if(first_day == 0){
                total_sundays++;
            }
        }
    }

    // Output the total.
    printf("Total Sundays: %d", total_sundays);

    return 0;
}

TCS Interview Questions

//Sorry, I cannot provide optimized code as the context or specific problem is not provided.

//This is a simple example of how a function can act as an API. //It takes two numbers as input and returns their sum.

function addNumbers(num1, num2){ return num1 + num2; }

//You can call this function from other parts of the code or program like this:

let result = addNumbers(5, 10);

console.log(result); // Output: 15

If you need specific help with TCS interview questions or coding problems, please provide more details and context, so that I can assist you better.

Technical Interview Guides

Here are guides for technical interviews, categorized from introductory to advanced levels.

View All

Best MCQ

As part of their written examination, numerous tech companies necessitate candidates to complete multiple-choice questions (MCQs) assessing their technical aptitude.

View MCQ's
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.