# Thread: Plz solve my problem !

1. ## Plz solve my problem !

Hello freinds can any body solve my little problem:-
Make this prog in C---
Enter a number from keyboard and we have to tell weather this number is odd or even without using Control statements ?

2. i think no one is going to code you the whole program.
show some effort!

3. I'd make 2 giant arrays, one containing all even numbers and one containing all odd numbers. If your number is in the odd array, it's odd. If it's in the even array, it's even.

4. I'd probably know what one was if I saw it but as far as jargon goes, what's a control statement?

5. >>I'd probably know what one was if I saw it but as far as jargon goes, what's a control statement?
if, switch, while, for, etc.

6. *sniff sniff* *sniff sniff* i smell homework, hmm......

7. ## Untested

void main(void)
{
char oddeven[][5]={"even","odd");
int number;

printf("Enter number:");
scanf("%d",&number);
printf("The number %d is %s",number,oddeven[number%2]);
}

8. Ouch..... you guys are so harsh.

See if this will work.

Code:
```#include <stdio.h>
#include <assert.h>

int main(void)
{
int num;

printf("enter a number: ");
scanf("%d", &num);

assert(num > 0);

printf("%d is %s", num, ((num % 2) == 0) ? "even" : "odd");

return 0;
}```

9. >>printf("%d is %s", num, ((num % 2) == 0) ? "even" : "odd");
I think the ?: operator counts as a control statement, penny was on the right track.
Code:
```#include <stdio.h>

int main(void)
{
int num;
char *eo[] = {
"odd",
"even",
};

printf("Enter a number: ");
fflush(stdout);

/* Should test that sccanf works */
/* but that means using a control statement */
scanf("%d", &num);
printf("%s\n", eo[num % 2 == 0]);

return 0;
}```

10. Originally posted by Cela
>>printf("%d is %s", num, ((num % 2) == 0) ? "even" : "odd");
I think the ?: operator counts as a control statement, penny was on the right track.
Hmph.... those picky profs

11. Code:
```#include <stdio.h>
int main(void)
{
int i;
printf("enter a number: ");
scanf("%d", &i);
(i%2)&&printf("The number is odd\n");
(!(i%2))&&printf("The number is even\n");
return 0;
}```

12. ## Here

#include <stdio.h>

int main(void)
{
int InputNumber=0;
int ReturnFunction=0;
char junk;

scanf("%d", &InputNumber);

ReturnFunction = (InputNumber%2);

if (ReturnFunction==0)
{
printf("\nThe Number is Even")
}
else
{
printf("\nThe Number is Odd")
}

getchar(junk);

return 0;
}