Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     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;
  7.     long double divide=0;
  8.     for(int x = 0; x<max; x++){
  9.         if(num[x]%2>0){
  10.             oddCtr+=1;
  11.             odd[oddCtr]=num[x];
  12.         }
  13.         else{
  14.             evenCtr+=1;
  15.             even[evenCtr]=num[x];
  16.         }
  17.         add+=num[x];
  18.         sub-=num[x];
  19.         if(x==0){
  20.             divide=num[x];
  21.             mult=num[x];
  22.         }
  23.         else{
  24.             divide/=num[x];
  25.             mult*=num[x];
  26.         }        
  27.     }
  28.     cout<<"Even Numbers: ";
  29.     for(int z = 0; z<=evenCtr;z++){
  30.             cout<<even[z];
  31.             if(z!=evenCtr){
  32.                 cout<<",";
  33.             }
  34.     }
  35.     cout<<"\n";cout<<"Odd Numbers: ";
  36.     for(int y = 0; y<=oddCtr;y++){
  37.             cout<<odd[y];
  38.             if(y!=oddCtr){
  39.                 cout<<",";
  40.             }
  41.     }
  42.     cout<<"\n"<<"Array computation";
  43.     cout<<"\n"<<"Multiplication: "<<mult;
  44.     cout<<"\n"<<"Division: "<<setprecision(30)<<fixed<<divide;
  45.     cout<<"\n"<<"Subtraction: "<<add;
  46.     cout<<"\n"<<"Addition: "<<sub;
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement