witam mam problem z ustaleniem warunków dla zmiennej k aby program poprawnie działał, póki co dla dodatnich wartości wszystko śmiga ale dla ujemnych wywala incorrect input, program musi być w funkcji switch, oto program:
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
int X;
printf("Podaj liczbe: ");
int c=!scanf("%d" , &X);
int k=(c<<2)+(X%2)+((2*X+1)>0);
switch(k)
{ case 1:
printf("X is even");
break;
case 2:
printf("X is odd");
break;
default:
printf("Incorrect input\n");
return 1;
}
return 0;
}