Print ODD EVEN in best possible way.

Below is a program for finding wether a number is odd or even. I have described three different approaches and the approach will indicate the level of programmer

  1. Programmer

  1. If(x%2==0){
  2. Print(“even”)
  3. }
  4. Else if(x%2!=0){
  5. Print(“odd”)
  6. }

2. Good programer


  1. If(x%2==0){
  2. Print(“even”)
  3. }
  4. Else{
  5. Print(“odd”)
  6. }

3. Great programmer


  1. Array={“even”,"odd”}
  2. Print(Array[x%2])
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: