#include <stdio.h>
int main()
{
int x;
printf("Input x: ");
scanf("%d", &x);
if (x < 0)
{
printf("x is negative.\n");
} else
{
if (x == 0)
{
printf("x is zero.\n");
} else
{
printf("x is positive.\n");
}
}
return 0;
}
|
|
- There you go.
- Notice the == symbol. This symbol is used in equality comparison.
Whereas the single equal sign (=) is used to assign variables.
- Remember this! This can lead to a simple but frustating mistake for beginning C/C++
programmers.
|