Write a program that asks for players, and then gives ateams, players left over.

Q17. A computer programming contest requires teams of 5 members each. Write a program that asks for the number of players, and then gives the number of teams and number of players left over.

Ans.

#include<iostream.h>  //for standard input and output

#include<conio.h>     //for clrscr()

 

//Main function

void main()

{

int no_of_players,no_of_teams,leftovers;

 

clrscr();  //for clear screen

 

cout<<“\n Enter the number of players: “;

cin>>no_of_players;

 

no_of_teams=no_of_players/5; //integre division

leftovers=no_of_players%5;

 

cout<<“\n There will be “<<no_of_teams<<” teams with “<<leftovers<<” left over.”;

 

getch();   //To hold the output screen

}

//End of main()

 

OUTPUT:

 

Enter the number of players: 56

There will be 11 teams with 1 left over.

Leave a Reply

Your email address will not be published. Required fields are marked *

469 Views
%d bloggers like this: