CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@Gaurav Deshmukh • 19 Sep, 2013 • 2 likes
#include<stdio.h>
#include<conio.h>

int main()
{
  int no;
  char ch[0]="Even";
  char ch[1]="odd";
  printf("Enter a no. \t");
  scanf("%d",&no);

  printf("\n The no. is %s",ch[no%2]);

return (0);
}
// in above c code using % operator and array we can find the no. is even or odd also we can perform it by using bitwise AND operato (&) and AND operator (&&).................
I gave u the hint can anybody is able to write 2nd program ...😉😀//

o/p--> Enter a no. 7
The no. is odd

Enter a no. 4
The no. is Even
@Anoop Kumar • 19 Sep, 2013 Good program but in wrong category.
You should post computer and IT related stuffs at following section:
https://www.crazyengineers.com/community/computer-science-it-networking.42/
@nareshkumar6539 • 19 Sep, 2013
Gaurav v. Deshmukh
#include<stdio.h>
#include<conio.h>

int main()
{
  int no;
  char ch[0]="Even";
  char ch[1]="odd";
  printf("Enter a no. \t");
  scanf("%d",&no);

  printf("\n The no. is %s",ch[no%2]);

return (0);
}
// in above c code using % operator and array we can find the no. is even or odd also we can perform it by using bitwise AND operato (&) and AND operator (&&).................
I gave u the hint can anybody is able to write 2nd program ...😉😀//

o/p--> Enter a no. 7
The no. is odd

Enter a no. 4
The no. is Even
When we use logical and or bit wise first it will convert number into binary format then it will perform the operation.
When we perform Logical and or Bitwise and operation with NUMBER&&1 it will give
one means it is ODD number it will give 0 means EVEN number.
(NUMBER&&1)?"ODD":"EVEN" or (NUMBER&1)?"ODD":"EVEN"
@rahul69 • 20 Sep, 2013
nareshkumar6539
When we use logical and or bit wise first it will convert number into binary format then it will perform the operation.
When we perform Logical and or Bitwise and operation with NUMBER&&1 it will give
one means it is ODD number it will give 0 means EVEN number.
(NUMBER&&1)?"ODD":"EVEN" or (NUMBER&1)?"ODD":"EVEN"
Logical And will not work! because logical And can only check if the number is non zero, to check even odd, you will have to use bitwise And ie '&'
@Vinut47 • 25 Jun, 2016 7 easy ways to find whether a number id odd/even.
C program to check odd or even number - 7 easy ways
4.1k views

Related Posts

@Jason Estibeiro · Mar 26, 2016

OLO first came into limelight when they won the World Maker Faire Editor’s Choice Award. The aim of the OLO team is to develop something that can be used by...
3.4k views

@Kaustubh Katdare · Mar 17, 2011

Alright, you've done fixing all the parts, writing code, getting all motors to work. The tougher part is ahead - naming your robot. Why not collect all the cool and...
3.8k views

@suyash · Jun 24, 2007

[FONT="]TATVA’07: A RETROSPECTIVE[/FONT] [FONT="]The Annual Technical Festival of the Department of Metallurgical and Materials Engineering, Visvesvaraya National Institute of Technology, Nagpur, had a successful inaugural edition which was organized from...
1.8k views

@Abhishek Rawal · Dec 20, 2014

Material Design is not just for Android device anymore. Quantum OS is using Material design guidelines to design the Quantum OS. The desktop is written using QML & QT5, the...
1.8k views

@Kaustubh Katdare · Jul 28, 2015

Given the interest of engineering students in preparing for the CDAC C-CAT exam, I thought of starting a dedicated discussion for all the C-CAT 2016 aspirants to share preparation tips...
82k views