{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Loops ex - C Repetition exercises Question 1 Write a...

This preview shows pages 1–5. Sign up to view the full content.

C++ Repetition exercises

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Question 1: Write a program, to enter 20 numbers: 1- Count all input numbers which are in the range 1. . 99 (inclusive). 2- Find the sum of all input numbers which are out of the previously mentioned range. 3- Display the count of (in range) numbers, and the sum of (out of range) numbers.
void main() { int count=20,inCount=0; float num,outSum=0; while (count-- > 0) { cout<< "enter a number:" ; cin>>num; if inCount++; else outSum+=num; } cout<< "count of in_range numbers is: “ <<inCount<<endl; cout<< "sum of out_of_range numbers is:” <<outSum<<endl; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Question 2: A group of "p" players are playing dice game (each player is represented by a number starting with 1), and each is allowed to roll two dices 5 times. Write a program to carry out the following tasks: 1- Calculate scores for all players and display them along with the player number. Note: The score for each player is calculated as follows: find the sum of the two dices, if the sum is greater than 6 it should be
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 9

Loops ex - C Repetition exercises Question 1 Write a...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online