Computer Science, asked by itzmewiki, 8 months ago

It was Raj's first day at school. His teacher Anu asked the students to meet every other student in the class and introduce about themselves. The teacher asked them to handshake with each other when they meet. If there are n number of students in the class then find the total number of handshakes made by the students. Write code in C++

Answers

Answered by bipinvjohn
1

#include<iostream>

using namespace std;  

int maxHandshake(int n)  

{  

return (n * (n - 1))/ 2;  

}  

int main()  

{  

int n;

cin>>n;  

cout << maxHandshake(n);  

return 0;  

}

Answered by pranalipatil3620
0

Answer:

#include<iostream>

using namespace std;

int main()

{

 int stud,Handshakes;

 cin>>stud;

 Handshakes=stud*(stud-1)/2; //Combination formula nC2

 cout<<Handshakes;

 return 0;

}

Explanation:

Similar questions