Question: Please write program in C/C++/Java and explain the steps for every logic of program because i am not understanding and getting confused. The question for

Please write program in C/C++/Java and explain the steps for every logic of program because i am not understanding and getting confused.

The question for the program is as follows :

At the annual meeting of Board of Directors of Acme Inc, every one starts shaking hands with everyone else in the room. Given the fact that any two persons shake hand exactly once, Can you tell the total count of handshakes?

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 Board of Directors of Acme.

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 

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!