Created
March 5, 2017 10:06
-
-
Save FelipeGrijo/f0d5b3f5c387db7646a74e502b7731cf to your computer and use it in GitHub Desktop.
4. Faça uma função que recebe um valor inteiro e verifica se o valor é positivo ou negativo. A função deve retornar um 1 quando verdadeiro e 0 para falso.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://gist.github.com/FelipeGrijo | |
#include <stdio.h> | |
int PouN(int vnum){ | |
int PN; | |
if(vnum >= 0){ | |
PN=1; | |
} | |
else{ | |
PN=0; | |
} | |
return PN; | |
} | |
int main(){ | |
int Num,ValorNum; | |
printf("Digite um numero para saber se e positivo ou negativo:"); | |
scanf("%d",&Num); | |
ValorNum=PouN(Num); | |
if(ValorNum == 1){ | |
printf("%d e positivo\n",Num); | |
} | |
else{ | |
printf("%d e negativo\n",Num); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment