Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Problem Statement - Tee Shirts Selection By Sports Teacher
A sports teacher has been confidentially asked to reject the persons whose Tee-shirt numbers are divisible by 10. Make a program to help this teacher collect the T-shirt numbers one by one and stop counting when 10 persons have been counted. Keep printing the selected Tee-shirt numbers.
Solution
TC++ #5011
Run Output
Enter T-Shirt Number :3
3
Enter T-Shirt Number :5
5
Enter T-Shirt Number :10
Enter T-Shirt Number :7
7
Enter T-Shirt Number :20
Enter T-Shirt Number :17
17
Enter T-Shirt Number :13
13
Enter T-Shirt Number :4
4
Enter T-Shirt Number :1
1
Enter T-Shirt Number :2
2
Enter T-Shirt Number :11
11
Enter T-Shirt Number :12
12
int n; //This will contain the number on the tee-shirt int count=1; //This counts the number of tee-shirts to be picked while(count<=10) //Loop till 10 tee-shirts are picked
{ cout<<“Enter T-Shirt Number :”; cin>>n; //Getting possible tee-shirt number from the user if(n%10==0) continue; //Use of continue to loop further if the number is divisible by 10 else
{ cout<<n<<” “<<endl; //Otherwise keep printing the selected number count++; //Count increases only when tee-shirt is selected
}
}