مرحبااا
سوري ما كنت اعرف القوانين ومن حقكم تغلقون الموضوع
المطلوب
Write a program that reads a list of integers from the keyboard and creates the following information:
a) Finds and displays the sum and the average of these integers.
B) Finds and displays the largest of these integers.
c) Finds and displays the smallest of these integers.
d) Displays YES if all of these integers are between 10 and 90 and NO if not.
e) Displays YES if some of these integers are less than 20 and NO if not.
The input data consist of a list of integers with a sentinel (9999). The program must ask the user to enter the integers, one by one, and enter the sentinel when the end of the list has been reached.
The output should appear as follows:
The sum of all these numbers is : -------
The average of all these numbers is : -------
The largest number is --------
The smallest number is --------
All these numbers are between 10 and 90 : ---------------
Some of these numbers are less than 20 : ---------------
وهاذي محاولتي وان شاء الله تعدلون فيها لنها مب ضابطه
بس يطلع لي sum , avg
#include<iostream>
using namespace std;
const int SENTINEL =9999;
int main ()
{
int num, i=0;
cout<<"Enter any integers(9999 to stop)/n";
int sum= 0;
double avg = 0;
cin>>num;
while(num!=SENTINEL)
{
sum= sum+num;
i++;
cin>>num;
}
cout<<"The sum of all these "<< i<<" numbers is :" <<sum<< endl;
if (i!=0)
cout<<"The average of all these numbers is :"<<sum/i<<endl;
int max=0;
int min=0;
cin>> num;
max= num;
for ( i=1; i<num; i++)
{
cin>>num;
if(num<max)
max= num;
else
(num<min);
min=num;
}
cout<<"The largest number is" << max<<endl;
cout<<"The smallest number is" << min<<endl;
if (min>= 10&& max<=90)
cout<<"All these numbers are between 10 and 90 :YES/n";
else
cout<<"All these numbers are between 10 and 90 :NO/n";
if (min<20)
cout<<"Some of these numbers are less than 20 : YES/n";
else
cout<<"Some of these numbers are less than 20 : NO/n";
return 0;
}
مشكوورين ويزاكم الله الف خير
