Today I attended the zoho written test in chennai. They have changed the written test pattern. Usually I expect a booklet of questions from them. But today I got a single question paper. It has 5 simple programming questions. We asked to write a program for those questions. They are very simple questions. We can choose whatever language we want. We are not allowed to use any collections. like ArrayList, Hashmap, string functions. Inputs can be hard coded. We can use print statements. We have to cover most of the use cases. These are the questions asked today. 1. Print the sum all the numbers in a given array example: 2 4 output: 8 -1 3 2. Print the count of non-continuous vowels in a given string: example: 1) W e lc o m e - output - 3 2) wood - output - 0 3. Count the number of 0's in the 8-bit representation of the given number: example: 1) 3 - 0000 0011 - output - 2 2) 23 - 0001 0111 - output - 4 4. Pr
/* Write a program to determine whether a given number can be expressed as sum of two prime numbers or not. For example 34 can be expressed as sum of two prime numbers but 23 cannot be. */ import java.util.*; import java.io.*; public class SumOfTwoPrime { public static void Primer(int num) { ArrayList<Integer> ar = new ArrayList<Integer>(); boolean flag=false; int prevPrime = 1; for(int i=1;i<=num;i++) { for(int j=2;j<i;j++) { if(i%j==0) { flag=false; break; } else flag=true; } if(flag==true) { ar.add(i); } } for(int i=0;i<ar.size();i++) { for(int j=0;j<ar.size();j++) { if( (ar.get(i))+(ar.get(j)) == num ) System.out.println(num+" is sum of two primes "+ar.get(i)+" and "+ar.get(j)); } } } public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Primer(n); } }