You must Sign In to post a response.
  • Program to calculate total number of handshakes made by people in a party.


    Are you learning C++ programming? Finding difficulty in writing the program for a problem? On this page our ISC experts shall guide you with a detailed C++ program solution for your query.

    Q.) Write a C++ program to calculate total number of handshakes made by people in a party. If n (Here user can assume any number like in a party if there were 30 people ) number of people at a party shook hands with each other. How many handshakes were there altogether?
  • Answers

    1 Answers found.
  • below is the program which describes how many handshakes were made in a party of n people.
    Please include iostream.h and conio.h header files before declaration of class.

    //PROGRAM TO CALCULATE TOTAL HANDSHAKES MADE BY PEOPLE IN A PARTY.
    #include
    #include
    class sample
    {
    private:
    int n;
    public:
    void get(int t)
    {
    n=t;
    cout<<"\nThere were "< }
    void calculate(void)
    {
    int r=0,i;
    for(i=n;i>=1;i--)
    {
    r=(r+(i-1));
    }
    cout<<"\nIn a party of "< }
    };
    void main(void)
    {
    class sample s;
    clrscr();
    int x;
    cout<<"\nEnter the number of people present in the party\n";
    cin>>x;
    s.get(x);
    s.calculate();
    getch();
    }


  • Sign In to post your comments