hi!!
i just started programming some stuff in c++.
i made a simple program that compares a number given by the user to 0 n say if its cero, positive or negative.

// num_positivo_negativo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <math.h>
#include <windows.h>
#include <stdio.h>
#include <iostream>    //para las versiones nuevas de C++
#include <iostream.h> //para las versiones más viejas, como Borland C++


int main(int argc,char* argv[])
{
	int num;

	cout << "     Ingrese un número:  ";
	cin << num;

	if (num = 0)
	{
 		cout << "El número es igual a cero";   // says that is 0
	}
	else
		if (num < 0)
		{
			cout <<"Numero negativo"; // says that is negative
		}
		else
		{ 
			cout <<"Numero positivo"; // says that is positive
		}

	
	

	return 0;

}

but, then it gave me this error:

num_positivo_negativo.cpp(17) : error C2676: binary '<<' : 'class istream_withassign' does not define this operator or a conversion to a type acceptable to the predefined operator


hope some1 can help me

thanks!!

cyaa!!

gispe!! :)

You don't want this:

cin << num;

you want this:

cin >> num;

Also, be careful here not to confuse the = (assignment) operator and the == (comparison) operator.

if (num = 0)

= should == in the line above.

thanks
didnt realized the last thing!!

thanks a lot

Don't include <iostream.h>. It's so called old stream header. Say him Nevermore. Use <iostream> only.

You wrote #include <stdafx.h> - Visual C++ precompiled header. Place all subsequent includes in stdafx.h wizard-generated file. No need in math.h, windows.h and stdio.h headers in your program now. You may add them (in stdafx.h) later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.