Skip to content

Instantly share code, notes, and snippets.

@FelipeGrijo
Created March 5, 2017 10:06
Show Gist options
  • Save FelipeGrijo/f0d5b3f5c387db7646a74e502b7731cf to your computer and use it in GitHub Desktop.
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.
//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