ahmed0saber

Even or Odd among 10 values in C++

Nov 7th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int i , a=0 , b=0 , list[10] , list1[10] , list2[10];
  6.     for(i=0;i<10;i++)
  7.     {
  8.         cout<<"Enter the value number "<<i+1<<" : ";
  9.         cin>>list[i];
  10.     }
  11.     for(i=0;i<10;i++)
  12.     {
  13.         if(list[i]%2==0)
  14.         {
  15.             list1[a]=list[i];
  16.             a++;
  17.         }
  18.         else
  19.         {
  20.             list2[b]=list[i];
  21.             b++;
  22.         }
  23.     }
  24.     cout<<"\n\n";
  25.     for(i=0;i<a;i++)
  26.     {
  27.         cout<<"The Even value number "<<i+1<<" is "<<list1[i]<<endl;
  28.     }
  29.     cout<<"\n\n";
  30.     for(i=0;i<b;i++)
  31.     {
  32.         cout<<"The Odd value number "<<i+1<<" is "<<list2[i]<<endl;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment