HomePrevious QuestionTCS Nqt Coding Questions 2024 | TCS ninja coding questions 2024

TCS Nqt Coding Questions 2024 | TCS ninja coding questions 2024

- Advertisement -
Telegram Group Join Now
Instagram Page Join Now
5/5 - (1 vote)

TCS Nqt Coding Questions 2024 | TCS ninja coding questions 2024 | tcs digital exam coding questions: If anyone have exam TCS NQT 2024 exam in upcoming month and you are looking for TCS Previous years coding question question and answer for Ninja,Digital and Prime Role then you are landed on right place.

Get ready for the upcoming TCS NQT exam next month with our platform! We’ve got a special collection of TCS coding questions from 2023-2024, covering everything from TCS Ninja to Digital Coding. Boost your preparation and guarantee success with our detailed answers. Don’t miss out on this helpful resource to ace the TCS NQT exam!

TCS Free NQT 2024 Apply Link: Click Here

TCS Nqt Coding Questions 2024:

Question 1:

Before the outbreak of corona virus to the world, a meeting happened in a room in Wuhan. A person who attended that meeting had COVID-19 and no one in the room knew about it! So everyone started shaking hands with everyone else in the room as a gesture of respect and after meeting unfortunately every one got infected! Given the fact that any two persons shake hand exactly once, Can you tell the total count of handshakes happened in that meeting?

Input Format :

The first line contains the number of test cases T, T lines follow. 

Each line then contains an integer N, the total number of people attended that meeting.

Output Format :

Print the number of handshakes for each test-case in a new line.

Constraints :

1 <= T <= 1000 

0 < N < 106 

Sample Input :

2

1

2

Output :

0

1

Explanation :

Case 1 : The lonely board member shakes no hands, hence 0. 

Case 2 : There are 2 board members, 1 handshake takes place.

Solution:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            long sum = (long) n * (n - 1) / 2;
            System.out.println(sum);
        }

    }
}

YouTube Video Solution:

tcs nqt coding questions 2024

Check Other TCS ninja coding questions 2024:

For TCS Ninja, Digital Question Click Here

For Daily Jobs & Internship Update Follow Us:

Join Telegram (Must)Click Here
Join Experienced Job TelegramClick Here
Follow Instagram Job Page Link:Join Here
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular