Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- using namespace std;
- int main()
- {
- int max =10;int num[max] = {10,9,8,7,6,5,4,3,2,1};int odd[5];int even[5];int mult=0,add=0,sub=0;int evenCtr=-1,oddCtr=-1;
- long double divide=0;
- for(int x = 0; x<max; x++){
- if(num[x]%2>0){
- oddCtr+=1;
- odd[oddCtr]=num[x];
- }
- else{
- evenCtr+=1;
- even[evenCtr]=num[x];
- }
- add+=num[x];
- sub-=num[x];
- if(x==0){
- divide=num[x];
- mult=num[x];
- }
- else{
- divide/=num[x];
- mult*=num[x];
- }
- }
- cout<<"Even Numbers: ";
- for(int z = 0; z<=evenCtr;z++){
- cout<<even[z];
- if(z!=evenCtr){
- cout<<",";
- }
- }
- cout<<"\n";cout<<"Odd Numbers: ";
- for(int y = 0; y<=oddCtr;y++){
- cout<<odd[y];
- if(y!=oddCtr){
- cout<<",";
- }
- }
- cout<<"\n"<<"Array computation";
- cout<<"\n"<<"Multiplication: "<<mult;
- cout<<"\n"<<"Division: "<<setprecision(30)<<fixed<<divide;
- cout<<"\n"<<"Subtraction: "<<add;
- cout<<"\n"<<"Addition: "<<sub;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement