Jump to content

erro quando digito 0

Jose Orlando

Recommended Posts

#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
	int num1,num2,soma,sub,mult,div;
	cout << "digite um valor:";
	cin >> num1;
	cout << "digite outro valor:";
	cin >> num2;
	cout << "resultado!\n" << "soma:" << soma << endl << "subtracao:" << sub << endl << "multiplicacao:" << mult << endl << "divisao:" << div;
	return 0;

se eu digito 0 para armazenar no num1 funciona normal, mais quando eu digito  0 para armazenar no num2 aparece que o progama parou de funcionar...

exemplo : 0 para armazena no num1 e 10 para armazena no num2 ele faz as operações  normal: soma=10, div= -10, mult=0 e div=0.

mais se eu inverte os valor:

exemplo : 10 para armazena no num1 e 0 para armazena no num2 o progama nao faz as operações e aparece o erro citado a cima.

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.