Last Updated on November 17, 2022 by Sumit Kumar
You will have a hard time in finding the interview round information about Top 10 Capgemini Interview Coding Questions, but relax we have collected the Latest Capgemini Interview Information from the previous drive students who were selected in the company, so please go through this page carefully while preparing for the Capgemini Interview Round
- After completing the first two rounds of the placement.
- You will be sitting in a personal interview round.
- Where you will be facing a panel of 3-4 executives.
This round can be further divided into 2 parts
- Technical Round
- HR Round
It depends on the executives what they may ask you, they can ask you only about your technical background and projects that you have mentioned in your resume, or else they can ask you only situation based HR questions. So you need to be well prepared for all the scenarios, below this page you can find some frequently asked questions in the interview round.
Capgemini Interview Coding Questions
Questions 1 Problem Statement – Bela teaches her daughter to find the factors of a given number. When she provides a number to her daughter, she should tell the factors of that number. Help her to do this, by writing a program. Write a class FindFactor.java and write the main method in it.
Note :
- If the input provided is negative, ignore the sign and provide the output. If the input is zero
- If the input is zero the output should be “No Factors”.
Sample Input 1:
54
Sample Output 1:
1, 2, 3, 6, 9, 18, 27, 54
Sample Input 2:
-1869
Sample Output 2 :
1, 3, 7, 21, 89, 267, 623, 1869
#include<iostream> using namespace std; int main () { int n; cin >> n; n = abs (n); if (n == 0) cout << "No factors"; else { for (int i = 1; i < n; i++) { if (n % i == 0) cout << i << ","; } cout << n; } return 0; }
Question 2 Problem Statement – Raj wants to know the maximum marks scored by him in each semester. The mark should be between 0 to 100 ,if it goes beyond the range display “You have entered invalid mark.”
Sample Input 1:
- Enter no of semester:
3 - Enter no of subjects in 1 semester:
3 - Enter no of subjects in 2 semester:
4 - Enter no of subjects in 3 semester:
2 - Marks obtained in semester 1:
50
60
70 - Marks obtained in semester 2:
90
98
76
67 - Marks obtained in semester 3:
89
76
Sample Output 1:
- Maximum mark in 1 semester:70
- Maximum mark in 2 semester:98
- Maximum mark in 3 semester:89
Sample Input 2:
- Enter no of semester:
3 - Enter no of subjects in 1 semester:
3 - Enter no of subjects in 2 semester:
4 - Enter no of subjects in 3 semester:
2 - Marks obtained in semester 1:
55
67
98 - Marks obtained in semester 2:
67
(-)98
Sample Output 2:
You have entered invalid mark.
#include<iostream> using namespace std; int main () { int n; cout << "Enter the number of semester: "; cin >> n; vector < int >sem (n); for (int i = 0; i < n; i++) { cout << "\nEnter number of subjects in " << i + 1 << " semester :"; cin >> sem[i]; } for (int i = 0; i < n; i++) { cout << "\nMarks obtained in " << i + 1 << " semester :"; int maxi = 0, mark; while (sem[i]--) { cin >> mark; if(!(mark <= 100 and mark >= 0)) { cout << "\nYou have entered invalid marks."; goto r; } maxi = max (maxi, mark); } cout << "\nMaximum mark in " << i + 1 << " semester :" << maxi; } return 0; }
Question 3 Problem Statement – Mayuri buys “N” no of products from a shop. The shop offers a different percentage of discount on each item. She wants to know the item that has the minimum discount offer, so that she can avoid buying that and save money.
[Input Format: The first input refers to the no of items; the second input is the item name, price and discount percentage separated by comma(,)]
Assume the minimum discount offer is in the form of Integer.
Note: There can be more than one product with a minimum discount.
Sample Input 1:
4
mobile,10000,20
shoe,5000,10
watch,6000,15
laptop,35000,5
Sample Output 1:
shoe
Explanation: The discount on the mobile is 2000, the discount on the shoe is 500, the discount on the watch is 900 and the discount on the laptop is 1750. So the discount on the shoe is the minimum.
Sample Input 2:
4
Mobile,5000,10
shoe,5000,10
WATCH,5000,10
Laptop,5000,10
Sample Output 2:
Mobile
shoe
WATCH
Laptop
#include<iostream> using namespace std; int main () { int n; cin >> n; vector vec(n); for(int i=0; i<n; i++) cin>>vec[i]; map<string,int>res; int mini=INT_MAX; for(int i=0; i<n;i++) { string temp =""; int num=0, per=0; int flag1=0, flag2=0; for(int j=0; j<vec[i].size(); j++) { if(vec[i][j]==',' and flag1==0) flag1=1; else if(vec[i][j]==',' and flag2==0) flag2=1; else if(vec[i][j]!=',' and flag1==0) temp += vec[i][j]; else if(vec[i][j]!=',' and flag2==0) num = (num*10)+(vec[i][j]-'0'); else per = (per*10)+(vec[i][j]-'0'); } int dis = (num*per)/100; if(dis<mini) mini= dis; res[temp] = dis; } for(auto it=res.begin(); it!=res.end(); it++) { if(it->second==mini) cout<first<<endl; } return 0; }
Questions 4 Problem Statement –
You have write a function that accepts, a string which length is “len”, the string has some “#”, in it you have to move all the hashes to the front of the string and return the whole string back and print it.
char* moveHash(char str[],int n);
example :-
Sample Test Case
Input:
Move#Hash#to#Front
Output:
MoveHashtoFront
#include <stdio.h> #include <string.h> char *moveHash(char str[],int n) { char str1[100],str2[100]; int i,j=0,k=0; for(i=0;str[i];i++) { if(str[i]=='#') str1[j++]=str[i]; else str2[k++]=str[i]; } strcat(str1,str2); printf("%s",str1); } int main() { char a[100], len; scanf("%[^\n]s",a); len = strlen(a); moveHash(a, len); return 0; }
Question 5 Problem Statement –
Capgemini in its online written test has a coding question, wherein the students are given a string with multiple characters that are repeated consecutively. You’re supposed to reduce the size of this string using mathematical logic given as in the example below :
Input :
aabbbbeeeeffggg
Output:
a2b4e4f2g3
Input :
abbccccc
Output:
ab2c5
import java.util.*; public class CharacterCount { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); int i, j, k = 0, count = 0; String uni = new String(""); for(i=0; i<str.length(); i++) { count = 0; for(j=0; j<=i; j++) { if(str.charAt(i)==str.charAt(j)) { count++; } } if(count==1) { uni = uni + str.charAt(i); } } for(i=0; i<uni.length(); i++) { count = 0; for(j=0; j<str.length(); j++) { if(uni.charAt(i)==str.charAt(j)) { count++; } } if(count==1) { System.out.printf("%c",uni.charAt(i)); } else { System.out.printf("%c%d",uni.charAt(i),count); } } } }
Question 6 Problem Statement –
Write the code to traverse a matrix in a spiral format.
Sample Input
Input
5 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
Output
1 2 3 4 8 12 16 20 19 18 17 13 9 5 6 7 11 15 12 14 10
#include<stdio.h> int main() { int a[5][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16},{17,18,19,20}}; int rs = 0, re = 5, cs = 0, ce = 4; int i, j, k=0; for(i=0;i<5;i++) { for(j=0;j<4;j++) { printf("%d\t",a[i][j]); } printf("\n"); } printf("\n"); while(rs<re && cs<ce) { for(i=cs;i<ce;i++) { printf("%d\t",a[rs][i]); } rs++; for(i=rs;i<re;i++) { printf("%d\t",a[i][ce-1]); } ce--; if(rs<re) { for(i=ce-1; i>=cs; --i) { printf("%d\t", a[re - 1][i]); } re--; } if(cs<ce) { for(i=re-1; i>=rs; --i) { printf("%d\t", a[i][cs]); } cs++; } } return 0; }
Question 7 Problem Statement –
You’re given an array of integers, print the number of times each integer has occurred in the array.
Example
Input :
10
1 2 3 3 4 1 4 5 1 2
Output :
1 occurs 3 times
2 occurs 2 times
3 occurs 2 times
4 occurs 2 times
5 occurs 1 times
import java.util.Scanner; public class ArrayFrequency { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int array[] = new int[n]; // taking value of integer int count = 0; int k = 0; for(int i=0; i<n; i++) { array[i] = sc.nextInt(); //elements of array } //step - 1 int newarray[] = new int[n]; for(int i=0; i<n; i++) { count = 0; for(int j=0; j<=i; j++) { if(array[i]==array[j]) { count++; } } if(count == 1) { newarray[k] = array[i]; k++; } } //step 2; for(int i=0; i<k; i++) { count = 0; for(int j=0; j<n; j++) { if(newarray[i] == array[j]) { count++; } } System.out.printf("%d occurs %d times\n",newarray[i],count); } } }
Question 8 Problem Statement –
Write a function to solve the following equation a3 + a2b + 2a2b + 2ab2 + ab2 + b3.
Write a program to accept three values in order of a, b and c and get the result of the above equation.
#include <iostream> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; int sum; sum=(a+b)*(a+b)*(a+b); cout<<sum; }
Question 9 Problem Statement –
IIHM institution is offering a variety of courses to students. Students have a facility to check whether a particular course is available in the institution. Write a program to help the institution accomplish this task. If the number is less than or equal to zero display “Invalid Range”.
Assume the maximum number of courses is 20.
Sample Input 1:
- Enter no of course:
5 - Enter course names:
Java
Oracle
C++
Mysql
Dotnet - Enter the course to be searched:
C++
Sample Output 1:
C++ course is available
Sample Input 2:
- Enter no of course:
3 - Enter course names:
Java
Oracle
Dotnet - Enter the course to be searched:
C++
Sample Output 2:
C++ course is not available
Sample Input 3:
- Enter no of course:
0
Sample Output 3:
Invalid Range
import java.util.*; class Main { public static void main(String[] args) { int n=0,flag=0; String courseSearch; Scanner sc = new Scanner (System.in); System.out.println("Enter no of course:"); n= sc.nextInt(); if(n<=0||n>20) { System.out.println("Invalid Range"); System.exit(0); } System.out.println("Enter course names:"); String[] course = new String[n]; sc.nextLine(); for (int i = 0; i < course.length; i++) { course[i] = sc.nextLine(); } System.out.println("Enter the course to be searched:"); courseSearch=sc.nextLine(); for (int i = 0; i < course.length; i++) { if(course[i].equals(courseSearch)) { flag=1; } } if(flag==1) { System.out.println(courseSearch+" course is available"); } else { System.out.println(courseSearch+" course is not available"); } } }
Question 10. Shraddha Kapoor’s professor suggested that she study hard and prepare well for the lesson on seasons. If her professor says month then, she has to tell the name of the season corresponding to that month. So write the program to get the solution to the above task?
- March to May – Spring Season
- June to August – Summer Season
- September to November – Autumn Season
- December to February – Winter Season
Note: The entered month should be in the range of 1 to 12. If the user enters a month less than 1 or greater than 12 then the message “Invalid Month Entered” should get displayed.
Sample Input 1:
Enter month: 6
Sample Output 1:
Season: Summer
Sample Input 2:
Enter month: 15
Sample Output 2:
Invalid Month Entered
#include<stdio.h> #include <stdlib.h> int main () { printf ("Enter the month:\n"); int entry; scanf ("%d", &entry); switch (entry) { case 12: case 1: case 2: printf ("Season: Winter"); break; case 3: case 4: case 5: printf ("Season: Spring"); break; case 6: case 7: case 8: printf ("Season: Summer"); break; case 9: case 10: case 11: printf ("Season: Autumn"); break; default: printf ("Invalid month Entered"); } return 0; }
Capgemini Interview Questions: FAQs
Q.1 What is the Purpose of this Coding Round?
Ans: Capgemini started conducting coding rounds this year to check the problem-solving skills of candidates.
Q.2 How many Questions are there in Capgemini?
Ans: A total of 3 questions are asked and you’ve to solve them in the time period of 75 minutes.
Q.3 What is the difficulty of Coding Questions?
Ans: The candidates who clear this round will get a package of 7.5 LPA. That’s why the difficulty level of this round is high and difficult.
Q.4 On which platform this coding round will be conducted?
Ans: Capgemini is using the Cocubes platform to conduct all their tests.
Q.5 Does Capgemini Ask Coding Questions?
Ans: Yes Capgemini asks coding questions for those who’ve applied for higher posts such as analysts with 7.5 LPA.
Q.6 Is their Coding Round in Capgemini?
Ans: Yes, Capgemini also conducts coding rounds for higher posts which consist of 3 questions with a time of 75 minutes.
Q.7 Does Capgemini take the Coding Test?
Ans: Yes, from this year onwards Capgemini is taking the Coding test to check the problem-solving ability of the candidates.
This article tried to discuss the Top 10 Capgemini Interview Coding Question . Hope this blog helps you understand and solve the problem. To practice more problems you can check out MYCODE | Competitive Programming at Prepbytes.