jeudi 17 novembre 2016

My IF program is incorrect

The problem I am having is the output is always '-1' regardless of what I enter.

The rules I must follow are: outputs -1 if the input number was less than zero; outputs 0 if the input number was exactly zero; outputs 1 if the input number was greater than zero.

Code is below:

#include <stdio.h>
int main ()
{
   int number;

printf("please enter a number: ");
scanf("%i", &number);

if("number > 0")
{
printf ("-1");
}
else if ("number == 0")
{
printf("0");
}
else if ("number < 0")
{
printf("1");
}
}

Aucun commentaire:

Enregistrer un commentaire