َالسوال الاول:
Write program that deal with array of integers that contains random values,
that's mean you should use rand() function that's generate array's elements. In
your program, you should sort the elements of randomly array. Then print your
array before and after sorting.
Output sample:-
Array which generated randomly :
-------------------------------
0 3 3 2 9 0 8 2 6 6
-------------------------------
Array's elements after sorted :
-------------------------------
0 0 2 2 3 3 6 6 8 9
-------------------------------
محاولتى
#include <iostream>
using namespace std;
void rond(int a[],int x){
cout<<"Enter";
for(x=0;x<10;x++)
cin>>a[x];
}
void sort(int a[],int x,int y){
for(x=0;x<10;x++)
for(y=1;y<10;y++)
}
int main(){
rond(a[],x);
stor(a[],x,y);
return 0;
}
السوال الثانى:
Write C++ program that define an array of strings word as following:-
string Fruits ={"apple", "orange" , "banana",
"grape" , "pear" , "strawberry" ,
"berry" , "peach" , "dates" };
Your program should ask user to enter any kind of fruits, then search in your
array to verify if it's in the list or no. Then print one of the following massages
up to the searching result.
Output samples:-
Search in the Fruit's Array!
apple
apple** is in the Fruits list!**
محاولتى :
#include <iostream>
#include<string>
using namespace std;
int main(){
string Fruits ={"apple", "orange" , "banana",
"grape" , "pear" , "strawberry" ,
"berry" , "peach" , "dates" };
cout<<"Enter a kind of fruit and I'll\nSearch in the Fruit's Array!";
string a;
cin>>a;
if(Fruits==a)
cout<<a<<"** is in the Fruits list!**";
else
cout<<a<<"** is not in Fruits list!**";
return 0;
}
السوال الثالث:
Write a program that read one dimensional array that contain of five elements from the
user, then do the following:-
Print all yours array's elements.
Define function which receives your array and calculate the mean of array's
elements and print return it.
Define another function that find the maximum value from array's elements
and print also return it.
Print both the mean and maximum values.
محاولتى
include<iostream>
using namespace;
int c[5];
cout<<"enter number;"
cin>>c[5];
int su(int sum )
{
sum+=c[5];
return sum; }
int maxum(int max,int c[5])
{
max=c[5];
return max;
}
int main()
{
su( sum );
maxum( max, c[5]);
return 0;
}