HomePrevious QuestionZOHO Programming Questions with Solutions | Zoho level 1 programming questions

ZOHO Programming Questions with Solutions | Zoho level 1 programming questions

- Advertisement -
Telegram Group Join Now
Instagram Page Join Now
whatsApp Channel Join Now
5/5 - (1 vote)

ZOHO Programming Questions with Solutions 2023 2024 | Zoho level 1 programming questions: Are you preparing for an upcoming Zoho company exam and in search of Zoho online test questions? You’ve landed in the right spot! Discover a comprehensive collection of Zoho’s previous exam questions along with detailed answers to aid in your preparation. Elevate your confidence and performance for the Zoho company exam by accessing valuable insights from our repository of past test questions. Prepare effectively and excel in your Zoho online test with our resourceful content.

Join Telegram Channel (43,530 Member)

Question 1: Zoho level 1 programming questions

Problem Statement:

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

Solution of Question 1 in C++:

#include<bits/stdc++.h>
using namespace std;
double comb(int n,int r)
{
if(r==0) return 1;
return n*comb(n-1,r-1)/r;
}
int main()
{
int n,r;
cin>>n>>r;
cout<<comb(n,r)/(1<<n);
}

Solution of Question 1 in JAVA:

import java.util.*;
class Main
{
public static int fact(int n)
{
if(n==0)
return 1;
return n*fact(n-1);
}
public static double count_heads(int n, int r)
{
double res;
res = fact(n) / (fact(r) * fact(n - r));
res = res / (Math.pow(2, n));
return res;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int r=sc.nextInt();
System.out.println(count_heads(n,r));
}
}

Solution of Question 1 in Python:

def comb(n, r):
if r==0:
return 1
return n*comb(n-1, r-1)/r
n, r = map(int, input().split())
print(comb(n,r)/(1<<n))

Question 2: zoho 2nd round programming questions

Problem Statement:

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

Solution of Question 2 in C++:

#include<bits/stdc++.h>
using namespace std;
map<int,string> m;
 
void fun(string s)
{
    string s1="",s2="";
    for(auto i:s)
    {
        if(i<='9'&&i>='0') s1+=i;
        else s2+=i;
    }
    m[stoi(s1)]=s2;
}
 
int main()
{
    string s;
    int c=0;
    getline(cin,s);
    istringstream ss(s);
    while(ss)
    {
        string word;ss>>word;
        if(word=="") break;
        fun(word);
        c++;
    }
    for(int i=0;i<c;i++)
    cout<<m[i]<<" ";
}

Solution of Question 2 in JAVA:

import java.util.*;
public class Main
{
  public static void main(String[] args)
{
   Scanner sc=new Scanner(System.in);
   String str=sc.nextLine();
   String[] arr=str.split(" ");
  String[] res=new String[arr.length];
  
for(int i=0;i<arr.length;i++)
{
   for(int j=0;j<arr[i].length();j++) { if(arr[i].charAt(j)>='0' && arr[i].charAt(j)<='9')
    {
      res[Integer.parseInt(arr[i].charAt(j)+"")]=arr[i].substring(0,j)+arr[i].substring(j+1,arr[i].length());
       break;
     }
}
}
String temp="";
for(int i=0;i<res.length;i++)
  temp=temp+res[i]+" ";
System.out.println(temp);
}
}

Solution of Question 2 in Python:

from collections import defaultdict
m=defaultdict(str)
s=list(map(str,input().split(" ")))
for i in s:
    s1=""
    s2=""
    for j in i:
        if j<='9' and j>='0':
            s1+=j
        else:
            s2+=j
    m[int(s1)]=s2
for i in range(len(s)):
    print(m[i],end=" ")

Question 3: zoho latest exam questions with solutions

Problem Statement:

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

Solution of Question 3 in C++:

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
string s1;
int idx=-1;
for(int i=0;i<s.length();i++)
{
if(s[i]=='.') idx=i;
else s1+=s[i];
}
int a=stoi(s1);
int p=1;
if(idx!=-1)
for(int i=0;i<s.length()-idx-1;i++)
p*=10;
int c=__gcd(a,p);
a/=c;p/=c;
cout<<a/p<<" "<<a-p*(a/p)<<"/"<<p;
}

Solution of Question 3 in JAVA:

import java.util.*;
public class Main
{
static long gcd(long a, long b)
{
if (a == 0)
return b;
else if (b == 0)
return a;
if (a < b)
return gcd(a, b % a);
else
return gcd(b, a % b);
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
double number=sc.nextDouble();
double intVal = Math.floor(number);
double fVal = number - intVal;
final long pVal = 1000000000;
long gcdVal = gcd(Math.round(
fVal * pVal), pVal);
long num = Math.round(fVal * pVal) / gcdVal;
long deno = pVal / gcdVal;
System.out.println((int)number+" " +
num + "/" + deno);
}
}

Solution of Question 3 in Python:

import math
s=input()
s1=""
idx=-1
for i in range(len(s)):
if s[i]=='.':
idx=i
else:
s1+=s[i]
a=int(s1)
p=1
if idx!=-1:
for i in range(len(s)-idx-1):
p*=10
c=math.gcd(a,p)
a//=c
p//=c
s=str(a//p)+" "+str(a-p*(a//p))+"/"+str(p)
print(s)

Question 4: ZOHO Programming Questions with Solutions

Problem Statement:

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

Solution of Question 4 in C++:

#include<bits/stdc++.h>
using namespace std;int main()
{
    string s;
    int c=0;
    getline(cin,s);
    for (auto i:s)
    {
        if(i=='(') c++;
        if(i==')') c--;
    }
    cout<<(c==0);
}

Solution of Question 4 in Python:

s=input()
c=0
for i in s:
    if i =='(':
        c+=1
    elif (i==')') and c>0 :
        c-=1
print(int(c>0))

For Other Zoho Practice Question check below:

ZOHO Practice question Click Here

For Daily Jobs & Internship Update Follow Us:

Join Telegram (Must)Click Here
Join Experienced Job TelegramClick Here
Follow Instagram Job Page Link:Join Here
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular