orlandoju

Ejer10_tp3

Apr 10th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main(void){
  6.  
  7.        int i,n1;
  8.        int primerimpar,segundoimpar;
  9.  
  10.        int contadorpares=0;
  11.  
  12.  
  13.     cout<< " Ingrese la cantidad de 7 numeros: "<<endl;
  14.   cout<<"--------------------"<<endl;
  15.    for (i = 0; i < 7; i++){
  16.  cin >> n1;
  17.    cout<<"--------------------"<<endl;
  18.     if(n1 %2 != 0 && contadorpares==0){
  19.         primerimpar=n1;
  20.         contadorpares++;
  21.  
  22.         }
  23.         else
  24.             if( n1 %2 !=0 && contadorpares==1 ){
  25.                 segundoimpar=n1;
  26.                 contadorpares++;
  27.             }
  28.             }
  29.  
  30.             cout<<"--------------------"<<endl;
  31.             cout<< " El primer numero impar es: "<<primerimpar<<endl;
  32.             cout<<"--------------------"<<endl;
  33.             cout<< " El segundo numero impar es: "<<segundoimpar<<endl;
  34.  
  35.  
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment