answersLogoWhite

0

#include
#include

int main(int argc, char *argv[]){
if(argc != 2) {
printf("pass one integer as an argument.\n");
exit(1);

}
if(atoi(argv[1]) % 2){
printf("That is an odd number\n");

}else{
printf("That is an even number\n");

}
return 0;

}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
ReneRene
Change my mind. I dare you.
Chat with Rene
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
More answers

CLS

PRINT "PROGRAM: Find if number is odd/or, even"

PRINT

INPUT "Enter number: ", number$

number% = VAL(number$)

PRINT

PRINT "The number is ";

IF number% MOD 2 = 0 THEN

PRINT "even."

ELSE

PRINT "odd."

END IF

END

User Avatar

Wiki User

14y ago
User Avatar

In twos-complement notation, if the least-significant bit is set, then the number is odd, otherwise its even.

In ones-complement notation, positive values follow the convention of twos-complement values while negative values use the opposing convention, if the least-significant bit is set then the number is even, otherwise it is odd.

A slower method but one that is common to both ones-complement and twos-complement is to use the modus of the value. The modus of a value is the remainder after dividing by another value. If the other value is 2 then the modus can only be 0 (even) or 1 (odd).

User Avatar

Wiki User

10y ago
User Avatar

In Java:

if (myNumber % 2 == 0)

System.out.println("The number is even.");

else

System.out.println("The number is odd.");

Similar in C or C++. The % operator is also used to check the remainder of a division, but you would have to change the output command.

User Avatar

Wiki User

14y ago
User Avatar

Get number

Divide number by 2 and store remainder

if remainder equal 0 print "Even"

if remainder equal 1 print "odd"

end program

User Avatar

Wiki User

15y ago
User Avatar

I need the program that can display this number

4

12

44

444

5555

66666

User Avatar

Wiki User

14y ago
User Avatar

bool IsNumberEven(int number)

{

if (number%2 == 0)

return true;

return false;

}

User Avatar

Wiki User

15y ago
User Avatar

Number = Val(Textbox1.text)

If Number Mod 2 = 0 then

MsgBox("It is even.")

End If

If Number Mod 2 <> 0 then

MsgBox("It is odd.")

End If

User Avatar

Wiki User

13y ago
User Avatar

void main()

{

int n;

printf("enter number :- ");

scanf("%d",&n);

(n%2==0)?"number is even" : "number is odd ";

getch();

}

User Avatar

Wiki User

14y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Write a programe to find whether a number is odd or even?
Write your answer...
Submit
Still have questions?
magnify glass
imp