# Zoho Coding Questions and Answers 2024 (Java/C/ C++/Python) | Zoho Coding Question 2024

## Zoho Coding Questions and Answers 2023-24 | Zoho Coding Questions in C | Zoho Coding Questions in Java | Zoho Coding Questions in C++ | Zoho Coding Questions in Java | Zoho Coding Questions With Answers

Zoho Coding Questions and Answers 2023-24: Both new graduates and professionals could think about working with Zoho. The coding test is medium complexity, meaning that while passing it is not impossible, it is also not very simple. If you practiced any of the code questions from the previous year’s test, you would undoubtedly have an advantage in the upcoming Zoho coding test. Let’s look at some test patterns, code problems, and solutions for C, C++, Java, Python, and Supercoder. In the below section, you may get the Zoho Coding Questions and Answers PDF/ Zoho Coding Questions With Solutions

Previous recruiting campaigns’ coding examinations placed a strong focus on arrays and other fundamental programming principles. One can easily pass the first round and even the ones after that if they prepare adequately. You must use your programming talents and choose a language you are comfortable with, such as C, C++, Java, or even Python, to complete the coding tasks. More details like Zoho Off-Campus Coding Questions and Answers, Zoho Coding Questions and Answers, Zoho Interview Questions and Answers, Zoho Interview Questions and Answers, Zoho Cut Off, Salary, Hike, Increment, Annual Appraisal, etc. are available on this page

### Pattern Programs

C program to print pyramid star patterns:

In this program, we will ask the user how many star pattern you want. Then, the user will type the integer and the compiler will start printing the star patterns on the screen.

//Learnprogramo
#include<stdio.h>
int main()
{
int row, c, n, temp;
printf(“Enter the number of rows in pyramid of stars you wish to see “);
scanf(“%d”,&n);
temp = n;
for ( row = 1 ; row <= n ; row++ )
{
/* for spacing purpose */
for ( c = 1 ; c < temp ; c++ )
printf(” “);
temp–;
/* for printing stars */
for ( c = 1 ; c <= 2*row – 1 ; c++ )
printf(“*”);
printf(“\n”);
}
}

### Output:

C program to print Pascal Number Triangle:

//Learnprogramo
#include<stdio.h>
long factorial(int);
int main()
{
int row, c, n, temp;
printf(“Enter the number of rows you wish to see in pascal triangle \n”);
scanf(“%d”,&n);
temp = n;
for ( row = 0 ; row < n ; row++ )
{
/* for spacing purpose */
for ( c = 1 ; c < temp ; c++ )
printf(” ” );
temp–;
/* for printing stars */
for ( c = 0 ; c <= row ; c++ )
printf(“%ld “,factorial(row)/(factorial(c)*factorial(row-c)));
printf(“\n”);
}
}
long factorial(int n)
{
int c;
long int result = 1;
for (c = 1; c <= n; c++)
result = result*c;
return result;
}

### Output:

C program to print Floyd’s Triangle:

//Learnprogramo
#include<stdio.h>
int main()
{
int n, row, c, a = 1;
printf(“Enter the number of rows of Floyd’s triangle to print\n”);
scanf(“%d”, &n);
for (row = 1; row <= n; row++)
{
for (c = 1; c <= row; c++)
{
printf(“%d “,a);
a++;
}
printf(“\n”);
}
}

### Zoho Coding Questions and Solutions in C

Q) Build a program for calculating and returning the sums of absolute differences between adjacent numbers in arrays of positive integers. This must be calculated from the position determined by the current user.

In the case of this coding problem, you use three positional arguments through a findTotalSum function. The three inputs you would require are the number of elements inside the array, the elements in the array and the position from where this function will take place.

For example, suppose the total number of elements is 5 and these are the elements:

1 2 3 6 4

Then, if we decide to start from the 3rd position or enter 3 as input, the function will occur from ‘3’, the 3rd number in the array.

Hence, the sum would be a total of (6-3)+(4-6)= 5

Here is the code:

``````#include <stdio.h>
#include <stdlib.h>
int findTotalSum(int n, int arr[], int start)
{
int difference, sum=0;
for(int i=start-1; i<n-1; i++)
{
difference = abs(arr[i]-arr[i+1]);
sum = sum + difference;
}
return sum;
}
int main()
{
int n;
int start;
scanf("%d",&n);
int array[n];
for(int i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
scanf("%d",&start);
int result = findTotalSum(n, array, start);
printf("\n%d",result);
return 0;
}``````

Q) Build a program that will allow you to find out how many clothing pieces in total of a certain length can be extracted from a particular number of cloth pieces. We can take the required length for each clothing piece as 10 feet.

In this case, we must first decide upon the length unit as feet and determine the inputs we need. For this function, we will need two inputs, first the number of pieces ( in the array) and the size of each piece in feet inside the array.

A cloth merchant has some pieces of cloth of different lengths. He has an order of curtains of length 12 feet. He has to find how many curtains can be made from these pieces. Length of pieces of cloth is recorded in feet.

For example, suppose the total number of elements is 3 and these are the elements:

0 10 40

Then, the first input is 3 followed by the second input of 0, 10 and 40.

Hence, the sum would be a total of 0 + (10/10) + (40/10) = 5

Thus, there could be 5 pieces of clothing extracted from these 3 pieces of cloth of variable sizes.

Here is the code:

``````#include <stdio.h>
int findTotalPieces(int n, int arr[])
{
int feet, total = 0;
for(int i=0; i<n; i++)
{
feet = arr[i] / 10;
total = total + feet;
}
}
int main()
{
int n;
scanf("%d",&n);
int array[n];
for(int i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
int result = findTotalPieces(n, array);
printf("%d",result);
return 0;
}``````

Q) A Cloth merchant has some pieces of cloth of different lengths. He has an order of curtains of length of 12 feet. He has to find how many curtains can  be made from these pieces. Length of pieces of cloth is recorded in feet.

Note : You are expected to write code in the findTotalCurtains function only which receive the first parameter as the number of items in the array and second parameter as the array itself. You are not required to take the input from the console.

Example

Finding the total curtains from a list of 5 cloth pieces.

Input
input 1 : 5
input 2 : 3 42 60 6 14

Output
9

Explanation
The first parameter 5 is the size of the array. Next is an array of measurements in feet. The total number of curtains is 5 which is calculated as under

3 -> 0
42 -> 3
60 -> 5
6 -> 0
14 -> 1
total = 9

Here is the code:

```#include <stdio.h>
int findTotalCurtains(int n, int arr[])
{
int feet, total = 0;
for(int i=0; i<n; i++)
{
feet = arr[i] / 12;
total = total + feet;
}
return total;
}
int main()
{
int n;
scanf("%d",&n);
int array[n];
for(int i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
int result = findTotalCurtains(n, array);
printf("%d",result);
return 0;
}```

Q) Write a program to find the difference between the elements at odd index and even index.

Note : You are expected to write code in the findDifference function only which receive the first parameter as the numbers of items in the array and second parameter as the array itself. You are not required to take the input from the console.

Example

Finding the maximum difference between adjacent items of a list of 5 numbers

Input
input 1 : 7
input 2 : 10 20 30 40 50 60 70

Output
40

Explanation
The first parameter 7 is the size of the array. Sum of element at even index of array is 10 + 30 + 50 + 70 = 160 and sum of elements at odd index of array is 20 + 40 + 60 = 120. The difference between both is 40

Here is the code:

```#include <stdio.h>
int findDifference(int n, int arr[])
{
int odd=0, even=0;
for(int i=0; i<n; i++)
{
if(i%2==0)
{
even = even + arr[i];
}
else
{
odd = odd + arr[i];
}
}
return even-odd;
}
int main()
{
int n;
scanf("%d",&n);
int array[n];
for(int i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
int result = findDifference(n, array);
printf("%d",result);
return 0;
}```

Q) Write a program to calculate and return the sum of absolute difference between the adjacent number in an array of positive integers from the position entered by the user.

Note : You are expected to write code in the findTotalSum function only which receive three positional arguments:

1st : number of elements in the array
2nd : array
3rd : position from where the sum is to be calculated

Example

Input
input 1 : 7
input 2 : 11 22 12 24 13 26 14
input 3 : 5

Output
25

Explanation

The first parameter 7 is the size of the array. Next is an array of integers and input 5 is the position from where you have to calculate the Total Sum. The output  is 25 as per calculation below.
| 26-13 | = 13
| 14-26 | =  12
Total Sum = 13 + 12 = 25

Here is the code:

```#include <stdio.h>
#include <stdlib.h>
int findTotalSum(int n, int arr[], int start)
{
int difference, sum=0;
for(int i=start-1; i<n-1; i++)
{
difference = abs(arr[i]-arr[i+1]);
sum = sum + difference;
}
return sum;
}
int main()
{
int n;
int start;
scanf("%d",&n);
int array[n];
for(int i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
scanf("%d",&start);
int result = findTotalSum(n, array, start);
printf("\n%d",result);
return 0;
}```

Q) Write a program to return the difference between the count of odd numbers and even numbers.

You are expected to write code in the countOddEvenDifference function only which will receive the first parameter as the number of items in the array and second parameter as the array itself. you are not required to take input from the console.

Example
Finding the difference between the count of odd and even numbers from a list of 5  number

Input
input 1 : 8
input 2 : 10 20 30 40 55 66 77 83

Output
-2

Explanation
The first paramter (8) is the szie of the array. Next is an array of integers. The calculation of difference between count sum of odd and even numbers is as follows:

3 (count of odd numbers) – 5 (count of even numbers) = -2

Here is the code:

```#include <stdio.h>
int countOddEvenDifference(int n, int arr[])
{
int odd = 0, even = 0;
for(int i=0; i<n; i++)
{
if(arr[i]%2==0)
{
even = even+1;
}
else
{
odd = odd+1;
}
}
return odd - even;
}
int main()
{
int n;
scanf("%d",&n);
int array[n];
for(int i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
int result = countOddEvenDifference(n, array);
printf("%d",result);
return 0;
}```

### Zoho Coding Questions and Solutions 2024

Question: Parallel Columbus

Problem Statement: Nobel Prize-winning Austrian-Irish physicist Erwin Schrödinger developed a machine and brought as many Christopher Columbus from as many parallel universes he could. Actually he was quite amused by the fact that Columbus tried to find India and got America. He planned to dig it further.

Though totally for research purposes, he made a grid of size n X m, and planted some people of America in a position (x,y) [in 1 based indexing of the grid], and then planted you with some of your friends in the (n,m) position of the grid. Now he gathered all the Columbus in 1,1 positions and started a race.

Given the values for n, m, x, y, you have to tell how many different Columbus(s) together will explore you as India for the first time.

Remember, the Columbus who will reach to the people of America, will be thinking that as India and hence wont come further.

Function Description:

Complete the markgame function in the editor below. It has the following parameter(s):

Parameters:

 Name Type Description n Integer The number of rows in the grid. m Integer The number of columns in the grid. x Integer The American cell’s Row. y Integer The American cell’s Column.

Constraints:

• 1 <= n <= 10^2
• 1 <= m <= 10^2
• 1 <= x <= n
• 1 <= y <= m

Input Format:

• The first line contains an integer, n, denoting the number of rows in the grid.
• The next line contains an integer m, denoting the number of columns in the grid.
• The next line contains an integer, x, denoting the American cell’s row.
• The next line contains an integer, y, denoting the American cell’s column.

Sample Cases

Sample Input 1

2

2

2

1

Sample Output 1

1

Explanation

The only way possible is (1,1) ->(2,1) -> (2,2), so the answer is 1.

C++ PROGRAM

```#include <bits/stdc++.h>
using namespace std;
unordered_map<int,long long int> f;

long long int Fact(int n)
{
if(f[n]) return f[n];
return f[n]=n*Fact(n-1);
}

int main()
{
int n,m,x,y;
cin>>n>>m>>x>>y;
n-=1;m-=1;x-=1;y-=1;
f[0]=f[1]=1;
int p=(Fact(m+n)/(Fact(m)*Fact(n)));
int imp=((Fact(x+y)/(Fact(x)*Fact(y)))*(Fact(m-x+n-y)/(Fact(m-x)*Fact(n-y))));
cout<<p-imp;
}```

PYTHON PROGRAM

```import math
n=int(input())-1
m=int(input())-1
x=int(input())-1
y=int(input())-1

ans=math.factorial(n+m)
ans=ans//(math.factorial(n))
ans=ans//(math.factorial(m))

ans1=math.factorial(x+y)
ans1=ans1//(math.factorial(x))
ans1=ans1//(math.factorial(y))

x1=n-x
y1=m-y

ans2=math.factorial(x1+y1)
ans2=ans2//(math.factorial(x1))
ans2=ans2//(math.factorial(y1))
print(ans-(ans1*ans2))```

Question: Airport Authority

Problem Statement -:

In an airport , the Airport  authority decides to charge some minimum amount to the passengers who are carrying luggage with them. They set a threshold weight value, say T, if the luggage exceeds the weight threshold you should pay double the base amount. If it is less than or equal to threshold then you have to pay \$1.

Function Description:

Complete the weightMachine function in the editor below. It has the following parameter(s):

Parameters:

 Name Type Description N Integer number of luggage T Integer weight of each luggage weights[ ] Integer array threshold weight

Returns: The function must return an INTEGER denoting the required amount to be paid.

Constraints:

• 1 <= N <= 10^5
• 1 <= weights[i] <= 10^5
• 1 <= T <= 10^5

Input Format for Custom Testing:

• The first line contains an integer, N, denoting the number of luggages.
• Each line i of the N subsequent lines (where 0 <= i <n) contains an integer describing weight of ith luggage.
• The next line contains an integer, T, denoting the threshold weight of the boundary wall.

Sample Cases:

• Sample Input 1
4
1
2
3
4
3
• Sample Output 1
5
• Explanation:
Here all weights are less than threshold weight except the luggage with weight 4 (at index 3) so all pays base fare and it pays double fare.

C PROGRAM

```#include <stdio.h>
long int weightMachine(long int N,long int weights[],long int T)
{
long int amount=0,i;
for(i=0;i<N;i++)
{
amount++;
if(weights[i]>T)
{
amount++;
}
}
return amount;
}
int main()
{
long int N,i,T;
scanf("%ld",&N);
long int weights[N];
for(i=0;i<N;i++)
{
scanf("%ld",&weights[i]);
}
scanf("%ld",&T);
printf("%ld",weightMachine(N,weights,T));

return 0;
}```

PYTHON PROGRAM

```def weightMachine(N,weights,T):
amount=0
for i in weights:
amount+=1
if(i>T):
amount+=1
return amount
N=int(input())
weights=[]
for i in range(N):
weights.append(int(input()))
T=int(input())
print(weightMachine(N,weights,T))```

Question: Self Sufficient

Problem Statement: Abhijeet is one of those students who tries to get his own money by part time jobs in various places to fill up the expenses for buying books. He is not placed in one place, so what he does, he tries to allocate how much the book he needs will cost, and then work to earn that much money only. He works and then buys the book respectively. Sometimes he gets more money than he needs so the money is saved for the next book. Sometimes he doesn’t. In that time, if he has stored money from previous books, he can afford it, otherwise he needs money from his parents.

Now His parents go to work and he can’t contact them amid a day. You are his friend, and you have to find how much money minimum he can borrow from his parents so that he can buy all the books.

He can Buy the book in any order.

Function Description:

Complete the function with the following parameters:

 Name Type Description N Integer How many Books he has to buy that day. EarnArray[ ] Integer array Array of his earnings for the ith book CostArray[ ] Integer array Array of the actual cost of the ith book.

Constraints:

• 1 <= N <= 10^3
• 1 <= EarnArray[i] <= 10^3
• 1 <=  CostArray[i] <= 10^3

Input Format:

• First line contains N.
• Second N lines contain The ith earning for the ith book.
• After that N lines contain The cost of the ith book.

Output Format: The minimum money he needs to cover the total expense.

Sample Input 1:

3

[3 4 2] [5 3 4]

Sample Output 1:

3

Explanation:

At first he buys the 2nd book, which costs 3 rupees, so he saves 1 rupee. Then he buys the 1st book, that takes 2 rupees more. So he spends his stored 1 rupee and hence he needs 1 rupee more. Then he buys the last book.

C++ PROGRAM

```#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, ans =0,sum=0;
cin>>n;
vector<int> arr1(n),arr2(n);
for(int i=0;i<n;i++) cin>>arr2[i];
for(int i=0;i<n;i++) cin>>arr1[i];
for(int i=0;i<n;i++) arr2[i]-=arr1[i];

sort(arr2.begin(),arr2.end(),greater<int>());
for(int i=0;i<n;i++)
{
sum+=arr2[i];
if(sum<0)
{ans+=abs(sum);sum=0;}
}
cout<<ans;
}```

PYTHON PROGRAM

```n=int(input())
L1=[0] *n
L2=[0]*n
for i in range(n):
L2[i]=int(input())
for i in range(n):
L1[i]=int(input())

for i in range(n):
L2[i]=L2[i]-L1[i];

L2.sort()
su=0
ans=0
for i in range(n):
su=su+L2[i]
if su<0:
ans = ans + abs(su)
su=0

print(ans)```

Keep an eye on Dailyrecruitment.in for the most up-to-date information about upcoming exams and results. Find out about official notices, Exam Patterns, Syllabus, Previous Question Papers, Coding Questions, Aptitude Questions, Expected Cut Off, Results, Merit List, Study Materials, and much more. Now is the time to bookmark in order to take advantage of even more amazing career opportunities.

### Govt Jobs by Qualifications

Education & Vacancies Salary Apply Link
10th Pass Govt Jobs - 5,000 Vacancies Rs. 5,200 - 63,200 Apply Now
12th Pass Govt Jobs - 18,000+ Vacancies Rs. 5,200 - 92,300 Apply Now
ITI Pass Jobs - 3,500 Vacancies Rs. 5,200 - 35,000 Apply Now
Any Graduate Jobs - 19,100 Vacancies Rs. 5,200 - 92,300 Apply Now
Central Govt Jobs Rs. 5,200 - 17,000 Apply Now
Bank Jobs - 1,000 Vacancies Rs. 5,200 - 29,200 Apply Now
Diploma Jobs - 9,300 Vacancies Rs. 5,200 - 35,000 Apply Now
BTech/BE Jobs - 18,000 Vacancies Rs. 15,000 - 1,00,000 Apply Now
Data Entry Jobs - 1,300 Vacancies Rs. 5,200 - 29,200 Apply Now
Private Jobs Rs. 10,000 - 67,700 Apply Now