Zoho Coding Questions and Solutions

Zoho Coding Questions

Coding is one of the most important sections in Zoho. Here are some questions, based on the pattern and difficulty level of the Previous Year’s Zoho Coding Questions.

Zoho coding questions

Question 1

Your task is to complete a function “count_heads()” that takes two inputs N and R. The function should return the probability of getting exactly R heads on N successive tosses of a fair coin. A fair coin has an equal probability of landing a head or a tail (i.e. 0.5) on each toss.

Example 1

  • Input: 1 1
  • Output: 0.500000

Example 2

  • Input: 4 3
  • Output: 0.250000

Question 2

Write a program that will print the sum of diagonal elements of a 10X10 matrix. The program will take a total of 100 numbers as input (10 numbers will be input per line and each number will be separated by a space).

Example 1

  • Input:    1  2 3 4 5 6 7 8 9 0 
                   0 1 2 3 4 5 6 7 8 0
                   3 4 5 6 7 8 9 6 4 0
                   2 3 4 5 6 7 8 9 3 2
                   3 4 5 6 7 4 3 2 1 3
                   3 4 5 6 2 4 4 2 4 6
                   2 3 4 6 2 4 6 2 3 5
                   2 3 5 6 2 4 6 2 3 5
                   2 4 6 2 1 4 3 3 5 2
                   3 3 5 2 4 6 2 1 4 6
  • Output:  42

Example 2

  • Input:   1 22 33 44 55 66 77 88 99 100
                  100 1 88 77 66 55 44 33 22 11
                  88 88 1 66 55 44 33 22 11 100
                  88 77 66 1 44 33 22 11 100 99
                  77 66 55 44  1 22  11 88 99 100
                  66 55 44 33 22 1 77 88 99 100
                  44 33 22 11 100 99 1 77 66 55
                  33 22 11 100 99 88 77 1 55 44
                  22 11 100 99 88 77 66 55 1 33
                  100 11 22 33 44 55 99 88 77 1
  • Output: 10

Question 3

Write a program that will take one string as input. The program will then remove vowels a, e, i, o, and u (in lower or upper case ) from the string. If there are two or more vowels that occur together then the program shall ignore all of those vowels.

Example 1

  • Input:  Cat
  • Output:  Ct

Example 2

  • Input:  Compuuter
  • Output: Cmpuutr

Question 4

Write a program that will take a string as input. The program will then determine whether each left parenthesis ‘(’ has a matching right parenthesis ‘)’ and also all the ‘)’ has a  consecutive ‘(‘. If so, the program will print 0 else the program will print 1.

Example 1

  • Input: HELLO AND (WELCOME (TO THE) TCEA (CONTEST)TODAY)IS (SATURDAY())
  • Output: 0

Example 2

  • Input: (9*(7-2)*(1*5)
  • Output: 0

Question 5

Write a program to find out and display prime numbers from the given list of integers. The program will accept input in two lines. First-line contains a number indicating the total number of integers in the list and the second line contains integers separated by spaces.

Example 1

  • Input: 5
               4 6 9 3 7
  • Output:  3 7

Example 2

  • Input:  10
                 8 10 3 12 7 15 11 2 17 26
  • Output:  3 7 11 2 17

Question 6

Write a program that will take a number as input. The program will convert the inputted number to a format, which will contain an integer part and a fraction part. The fraction part needs to be reduced to its lowest representation. The input will not contain any repeating decimals e.g. 1.3333…33. The output will be :

The integer part of the number ++fraction using a ’/’

Example 1 

  • Input:  2.95
  • Output:  2 19/20

Example 2

  • Input:  3.08
  • Output:  3 2/25

Question 7

Given a sentence with numbers representing a word’s location in the sentence, embedded within each word, and return the sorted sentence. 

Note: We are using a maximum of 0-9 numbers only for 1 sentence

Example 1

  • Input:  is1 Thi0s T3est 2a
  • Output:  This is a Test

Example 2

  • Input:  t2o j3oin 4WonderBiz I0 Technolog5ies wan1t
  • Output:  I want to join WonderBiz Technologies

Question 8

Write a program that takes an integer M and M integer array elements as input. The program needs to find the minimum difference between two elements in the integer array. The program then needs to print all those pairs of elements that have the minimum difference. If more than one pair has the minimum difference, then the program should print the output in the ascending order, if an element exists in two or more pairs, then it should be printed two times or more.

Example 1

  • Input: 4
               55 44 33 22
  • Output:  22 33 33 44 44 55
  • Explanation: The minimum difference between two elements is 11. Hence the pairs are printed in the ascending order. Here 33 and 44 appear in two different pairs; hence both are printed twice.

Example 2

  • Input: 5
               1 99 22 44 1001
  • Output:  1 22

Question 9

Write a program to convert a number to binary format.

Example 1

  • Input:  0
  • Output:  0

Example 2

  • Input:  1
  • Output:  1 

Question 10

Write a program that receives a word A and some texts as input. You need to output the texts (without modifying them) in the ascending order of the number of occurrences of the word A in the texts. The input is as follows: an integer M(between 1 and 100, inclusive), followed by the word A in the next line, and some text in each of the M next lines.

Note: The texts and the word A contain only lowercase Latin letters (a,b,c…,z) and blank spaces (“ ”). The maximum size of the texts and the word A is 100 Characters. Every text has a different number of occurrences of the word A.

Note 2:you must print one text per line without modifying the texts.

Example 1

  • Input: 2
               Java
                I hate java 
                Python is a good programming language
  • Output: Python is a good programming language
                  I hate java

Example 2

  • Input:  3
                python
                I like to code in python
                python is named after a show name monty python and not after the snake python
                I think python is good i think python is important than php
  • Output: i like to code in python
                  i think python is good i think python is important than php
                  python is named after a show name monty python and not after the snake python