• Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
CODE OF GEEKS

We at CODE OF GEEKS, aim at providing best and quality content for our users at no extra cost.

    • Study Materials – Company wise
      • Infosys Archive
      • Accenture Archive
      • AMCAT Archive
      • Capgemini Archive
      • Cisco Archive
      • CoCubes Archive
      • Cognizant(CTS) Archive
      • Dell Archive
      • Deloitte Archive
      • DXC Archive
      • Goldman Sachs Archive
      • Hexaware Technologies Archive
      • LTI Archive
      • MindTree Archive
      • TCS Archive
      • Virtusa Archive
      • Wipro Archive
    • Interview Preparation – E Books
      • C Interview Questions
      • Data Structures Interview Questions
      • DBMS Interview Questions
      • HR Interview Questions
      • Java Interview Questions
      • Operating System Interview Questions
      • Python Interview Questions
      • SQL Query Interview Questions
    • Programming
      • C Programming MCQs
      • C Code Snippets – Output Questions
      • Python Code Snippets – Output Questions
    • Aptitude
      • Verbal Ability for Placements
      • Quant for Placements
    • Register
    • Login
  • [email protected]
  • ..
Login / Register
Apply Now
CODE OF GEEKS
CODE OF GEEKS
  • Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
0

Cart

CoCubes Coding Questions

  • July 1, 2020
  • CODE OF GEEKS
  • 0

1. Problem Statement 1 [2020]

You are required to implement the following function :

int SumNumbersDivisible(int m, int n);

The function accepts two positive integers ‘m’ & ‘n’ as its arguments. You are required to calculate the sum og numbers divisible by both 3 and 5 between the inclusive range of m and n.

0<m<=n

Sample Testcase :

I/P

m=12

n=50

O/P

90

Solution

int SumNumbersDivisible(int m, int n)
{
int sum=0;
for(int i=m;i<=n;i++)
{
if(i%3==0 && i%5==0)
{
sum+=i;
}
}
return sum;
}

2. Problem Statement 2 [2020]

The function accepts integers ‘dir’, ‘d1’, ‘s1’, ‘d2’ and ‘s2’ as its argument. ‘d1’ & ‘d2’ are the distances and ‘s1’ & ‘s2’ are the speeds of first and second person respectively. Implement the function to find ‘time1’ and ‘time2’, which is the time taken by 1st and 2nd person respectively and return relative time as per given conditions :

if dir = 0, relative time = time1 + time2

if dir = 1, relative time = time1 + time2

Also, time = distance/speed

Assumption :

tim1 >= time2

d1, d2, s1, s2 are greater than 0.

dir is either 1 or 0.

Sample Testcases

I/P

dir=0

d1=30

s1=5

d2=20

s2=10

O/P

8

int relativeSpeed(int dir, int d1, int s1, int d2, int s2)
{
int res=0;
t1 = (int) d1/s1;
t2 = (int) d2/s2;
if(dir==0)
{
res=t1+t2;
}
else
{
res=t1-t2;
}
return res;
}

3. Problem Statement 3 [2020]

Least Common Multiple (LCM) of three Integers x,y,x is the smallest positive integer that is divisible by all three numbers x, y, z.

You are given a function :

int FindLeastCommonMultiple(int x, int y, int z);

The function takes three positive integers, x, y, z as input. Code this function to return the LCM of three numbers.

Sample Testcases :

I/P :

2 3 4

O/P

12

Explanation :

LCM of 2, 3, 4 is 12.

For solution, follow

https://codeofgeeks.com/lcm-of-two-numbers-using-c/

4. Problem Statement 4 [2020]

You are given a function :

int* ReverseArray(int* arr, int length);

The function takes an integer array and its length as an input.

Implement the function to return the array such that the array is reversed.

Sample Testcases :

I/P

7

2 3 4 1 2 4 6

O/P

6 4 2 1 4 3 2

Logic : Take one more array of same length as the input array. Traverse the given array from last element i.e from arr.length – 1 (keeping 0-based indexing in mind) and insert it to the new array.

New Array will be the reversed of input array.



5. Problem Statement 5

Count the number of co-prime pairs in an array. (Any two numbers whose GCD is 1 are be called as co-prime)
Input is given in following form : The first line contains an integer T, total number of elements. Then follow T elements.
Your job is to count the number of co-prime pairs in an array.

Constraints:

1 <= T <= 25
1 <= elements <= 100

Sample Testcases

I/P

3
1 2 3

O/P:

3

Co-prime pairs : (1, 2), (2, 3), (1, 3)

6. Problem Statement 6

You are given a function :

int FindSecondLargestNumber(int a,int b,int c);

The function takes three integers a, b, c as input .Implement the function to find and return the second largest number

Sample Testcases :

I/P

4 5 6

O/P

5

7. Problem Statement 7

You are given a function :

int SearchElement(int *arr, int item);

The function takes one array of ‘n’ integers and item to search as input. Code this function to search the position of this item in the array. If not present, print -1.

Sample Testcases :

I/P :

5

3 4 5 3 7

5

O/P

3

MORE CODING QUESTIONS :

8. Convert the given integer to its equivalent binary form.

9. Given a string in lowercase convert and print that in upper case.

10. Given the list of keywords, predict whether the given number is a keyword or not.

11. Given a string of characters, complete the function in order to find the unique characters from the list.

12. Program to find out the sum of cubes of ‘n’ natural numbers.



  • Previous AMCAT Aptitude Questions [Last Year]
  • Next CoCubes Logical Reasoning [Last Year]

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Cocubes Study Materials

  • Cocubes Complete Analysis Exam Pattern
  • Cocubes Quant Questions
  • Cocubes Logical Reasoning Questions
  • Cocubes Verbal Ability Questions
  • Cocubes Pseudo Code Questions
  • Cocubes Coding Questions

Study Materials : Company Wise

CODE OF GEEKS

Subscribe to Newsletter

CODE OF GEEKS

Learn | Code | Achieve

Reach us

[email protected]
We at CODE OF GEEKS, aim at providing quality content to our users at no cost.
CODE OF GEEKS

Important Pages

About us
Advertise
Privacy Policy
Terms and Conditions

Placements – Study Materials

TCS NQT     Wipro     CapGemini
Accenture     MindTree     CTS
DXC     Hexaware Technologies     AMCAT
CoCubes     Goldman Sachs     Dell
Cisco     Deloitte     Virtusa     LTI     Infosys   

Courses

  • Mail Us
  • Login/Register

Recent Posts

What is Cloud Computing | Cloud Computing Applications | Cloud Development Models| SaaS vs PaaS vs IaaS
  • October 23, 2021
What is Amazon Web Services | AWS Regions & AZs | Different AWS Services
  • October 19, 2021

Copyright 2021 CODE OF GEEKS. All Rights Reserved.

  • →