Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

To find whether a number is even or odd without using any
conditional operator??

Answer Posted / amala v

import java.io.*;

public class even {
public static void main(String arg[])throws IOException
{
String a[]={"even","odd"};
int p;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter a number to find:");
int n=Integer.parseInt(br.readLine());
p=n%2;
System.out.println("The Number is :"+a[p]);


}
}

Is This Answer Correct ?    24 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to print largest number of each row of a 2D array

2323


Why #include is used in c language?

1046


Explain bit masking in c?

1134


What is the translation phases used in c language?

1119


What are the features of c language?

1064


Write a program to swap two numbers without using third variable?

1289


What is identifiers in c with examples?

1169


Why is c so popular?

1163


What are qualifiers?

1044


Why does this code crash?

1085


How can I trap or ignore keyboard interrupts like control-c?

1062


What is the use of gets and puts?

1026


What is pointer to pointer in c?

1104


the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above

1247


How can I ensure that integer arithmetic doesnt overflow?

1160