Skip to content

Instantly share code, notes, and snippets.

@joepreludian
Created December 11, 2013 12:55
Show Gist options
  • Save joepreludian/7909951 to your computer and use it in GitHub Desktop.
Save joepreludian/7909951 to your computer and use it in GitHub Desktop.
Primeira questão de Eliselma - Trabalho.
//
// 1) Negativo
//
// Lê 5 valores inteiros, um de cada vez, conta quantos destes valores são negativos e imprime esta informação.
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
cout << "Números negativos\n\nPor favor, insira 5 numeros:\n";
int quantidade_negativos = 0;
int numero;
for (int i=1; i<=5; i++) {
cout << "Entre com o " << i << "o numero: ";
cin >> numero;
if (numero < 0) {
quantidade_negativos++;
}
}
cout << "A quantidade de números negativos foi: " << quantidade_negativos;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment