Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*1
- Hacer un programa para ingresar una lista de números que finaliza cuando se ingresa un cero, luego informar cuántos son positivos y cuántos son negativos.
- Ejemplo: 4, -3, 8, -5, 18, 20, 0. Se listará Positivos: 4 Negativos: 2.*/
- #include <iostream>
- using namespace std;
- int main(void){
- int i,n;
- int cpos=0;
- int cneg=0;
- do
- {
- cout<< " Ingrese un numero: "<<endl;
- cin>>n;
- cout<<"--------------------"<<endl;
- if(n>0)
- {
- cpos++;
- }
- else if(n<0)
- {
- cneg++;
- }
- }
- while(n!=0);
- cout<< "Positivos: " << cpos << endl;
- cout<<"Negativos: "<< cneg << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment