Array programming
Write a C Program to fill up an Integer Array. The length of
the array must take from the terminal. After fill up the array do the following
operations.
i)
Print the array with label formatting.
ii)
Count the number of values inside the array.
iii)
Count the number of odd values.
iv)
Count the number of even values.
v)
Sum all the odd values.
vi)
Sum all the even values.
vii)
Calculate the average.
viii)
Find the largest value.
ix)
Find the smallest value.
ID:201820244
ReplyDeleteBatch:58th
Section:B
#include
#define ARRAY_SIZE 100
using namespace std;
class Insert{
public:
int a_size;
int arr[ARRAY_SIZE];
Insert(){ //This is the constructor
cout << "Enter the array length: ";
cin >> a_size;
cout <<"Enter "<> arr[i];
}
}
~Insert(){} //This is the destructor
int arr_read(){
cout <<"\nThe array is: ";
for (int i=0; i= arr[i]){
max = max;
}
else{
max = arr[i];
}
}
cout<<"\nThe Maximum value is: "<<max<<endl;
}
};
int main()
{
Insert Ins;
Ins.arr_read();
Ins.odd_even_count();
Ins.odd_even_sum();
Ins.average();
Ins.minimum();
Ins.maximum();
return 0;
}
ID: 201820333
ReplyDeleteBatch: 58Th
Section: B
#include
#define ARRAY_SIZE 100
using namespace std;
class Insert{
public:
int a_size;
int arr[ARRAY_SIZE];
Insert(){ //This is the constructor
cout << "Enter the array length: ";
cin >> a_size;
cout <<"Enter "<> arr[i];
}
}
~Insert(){} //This is the destructor
int arr_read(){
cout <<"\nThe array is: ";
for (int i=0; i= arr[i]){
max = max;
}
else{
max = arr[i];
}
}
cout<<"\nThe Maximum value is: "<<max<<endl;
}
};
int main()
{
Insert Ins;
Ins.arr_read();
Ins.odd_even_count();
Ins.odd_even_sum();
Ins.average();
Ins.minimum();
Ins.maximum();
return 0;
}