Skip to content

Capgemini Coding Questions 2025 - Game-Based & Hands-on Coding Problems

Practice 25+ Capgemini placement paper coding questions with detailed solutions. Access Capgemini game-based assessment and hands-on coding problems in C, C++, Java, Python for Capgemini placement 2025-2026.

Capgemini Placement Paper Coding Questions - Complete Guide

Section titled “Capgemini Placement Paper Coding Questions - Complete Guide”

Practice with 25+ Capgemini placement paper coding questions covering the Capgemini game-based assessment and hands-on coding test. These questions are representative of what you’ll encounter in Capgemini’s online assessment.

What’s Included:

  • 25+ Coding Problems: Easy and Medium level problems with solutions
  • Multiple Language Solutions: C, C++, Java, and Python solutions
  • Time Complexity Analysis: Every solution includes complexity analysis
  • Capgemini-Specific Patterns: Focus on pseudocode, basic programming, arrays, strings

Capgemini Placement Papers 2024

Access 2024 Capgemini questions with solutions and exam pattern analysis.


View 2024 Papers →

Capgemini Placement Papers 2025

Practice latest 2025 Capgemini questions with updated patterns.


View 2025 Papers →

Complete Capgemini Guide

Access complete Capgemini placement papers guide with eligibility, process, and preparation strategy.


View Complete Guide →

Capgemini Assessment Coding Section Breakdown:

SectionQuestionsTimeDifficultyFocus Areas
Game-Based (Pseudocode)15 MCQs25 minEasy-MediumPseudocode, logic, tracing
Hands-on Coding245 minEasy-MediumArrays, strings, basic algorithms

Languages Allowed: C, C++, Java, Python

Q1: Loop Output Prediction

Question: What is the output of the following pseudocode?

SET x = 5
SET y = 0
WHILE x > 0 DO
SET y = y + x
SET x = x - 1
ENDWHILE
PRINT y

Options:

  • A) 10
  • B) 15
  • C) 20
  • D) 5

Answer: B) 15

Explanation:

  • x=5: y = 0+5 = 5, x = 4
  • x=4: y = 5+4 = 9, x = 3
  • x=3: y = 9+3 = 12, x = 2
  • x=2: y = 12+2 = 14, x = 1
  • x=1: y = 14+1 = 15, x = 0
  • Loop ends, y = 15
Q2: Conditional Statement

Question: What is the output?

SET a = 10
SET b = 20
IF a > b THEN
PRINT a
ELSE
IF a == 10 THEN
PRINT b + a
ELSE
PRINT b - a
ENDIF
ENDIF

Options:

  • A) 10
  • B) 20
  • C) 30
  • D) -10

Answer: C) 30

Explanation: a (10) is not > b (20), so else executes. a == 10 is true, so b + a = 30.

Q3: Array Traversal

Question: What is the output?

SET arr = [1, 2, 3, 4, 5]
SET sum = 0
FOR i = 0 TO 4 DO
IF arr[i] MOD 2 == 0 THEN
SET sum = sum + arr[i]
ENDIF
ENDFOR
PRINT sum

Options:

  • A) 6
  • B) 9
  • C) 15
  • D) 5

Answer: A) 6

Explanation: Even numbers in array are 2 and 4. Sum = 2 + 4 = 6.

Q4: Nested Loop

Question: What is the output?

SET count = 0
FOR i = 1 TO 3 DO
FOR j = 1 TO i DO
SET count = count + 1
ENDFOR
ENDFOR
PRINT count

Options:

  • A) 3
  • B) 6
  • C) 9
  • D) 4

Answer: B) 6

Explanation:

  • i=1: j runs 1 time (count=1)
  • i=2: j runs 2 times (count=3)
  • i=3: j runs 3 times (count=6)
Q5: String Operation

Question: What is the output?

SET str = "CAPGEMINI"
SET count = 0
FOR i = 0 TO LENGTH(str) - 1 DO
IF str[i] == 'A' OR str[i] == 'E' OR str[i] == 'I' THEN
SET count = count + 1
ENDIF
ENDFOR
PRINT count

Options:

  • A) 2
  • B) 3
  • C) 4
  • D) 5

Answer: C) 4

Explanation: Vowels in “CAPGEMINI”: A, E, I, I = 4 vowels.

Sum of Array Elements

Problem: Find the sum of all elements in an array.

Example:

Input: [1, 2, 3, 4, 5]
Output: 15

Solution (Java):

public int arraySum(int[] arr) {
int sum = 0;
for (int num : arr) {
sum += num;
}
return sum;
}

Solution (Python):

def array_sum(arr):
return sum(arr)

Solution (C):

int arraySum(int arr[], int n) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += arr[i];
}
return sum;
}

Time Complexity: O(n) | Space Complexity: O(1)

Find Second Largest

Problem: Find second largest element in array.

Example:

Input: [12, 35, 1, 10, 34]
Output: 34

Solution (Java):

public int secondLargest(int[] arr) {
int first = Integer.MIN_VALUE;
int second = Integer.MIN_VALUE;
for (int num : arr) {
if (num > first) {
second = first;
first = num;
} else if (num > second && num != first) {
second = num;
}
}
return second;
}

Solution (Python):

def second_largest(arr):
first = second = float('-inf')
for num in arr:
if num > first:
second = first
first = num
elif num > second and num != first:
second = num
return second

Time Complexity: O(n) | Space Complexity: O(1)

Reverse Array

Problem: Reverse an array in-place.

Example:

Input: [1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1]

Solution (Java):

public void reverseArray(int[] arr) {
int left = 0, right = arr.length - 1;
while (left < right) {
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}
}

Solution (Python):

def reverse_array(arr):
left, right = 0, len(arr) - 1
while left < right:
arr[left], arr[right] = arr[right], arr[left]
left += 1
right -= 1

Time Complexity: O(n) | Space Complexity: O(1)

Find Duplicates

Problem: Find duplicate elements in array.

Solution (Java):

public List<Integer> findDuplicates(int[] arr) {
Set<Integer> seen = new HashSet<>();
List<Integer> duplicates = new ArrayList<>();
for (int num : arr) {
if (seen.contains(num)) {
if (!duplicates.contains(num)) {
duplicates.add(num);
}
} else {
seen.add(num);
}
}
return duplicates;
}

Solution (Python):

def find_duplicates(arr):
seen = set()
duplicates = set()
for num in arr:
if num in seen:
duplicates.add(num)
seen.add(num)
return list(duplicates)

Time Complexity: O(n) | Space Complexity: O(n)

Rotate Array

Problem: Rotate array to the left by k positions.

Example:

Input: arr = [1, 2, 3, 4, 5], k = 2
Output: [3, 4, 5, 1, 2]

Solution (Java):

public void rotateLeft(int[] arr, int k) {
int n = arr.length;
k = k % n;
reverse(arr, 0, k - 1);
reverse(arr, k, n - 1);
reverse(arr, 0, n - 1);
}
private void reverse(int[] arr, int start, int end) {
while (start < end) {
int temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
}
}

Solution (Python):

def rotate_left(arr, k):
n = len(arr)
k = k % n
return arr[k:] + arr[:k]

Time Complexity: O(n) | Space Complexity: O(1)

Master Pseudocode

  • Practice tracing code
  • Understand loops and conditionals
  • Know array indexing
  • Read carefully for edge cases

Master One Language

  • Choose C, C++, Java, or Python
  • Know standard library functions
  • Practice writing code quickly
  • Handle I/O properly

Time Management

  • Pseudocode: ~1.5 min/question
  • Coding: ~20 min/problem
  • Read problem carefully
  • Test with given examples

Common Mistakes to Avoid

  • Off-by-one errors
  • Not handling empty inputs
  • Wrong output format
  • Not considering edge cases
Practice More Capgemini Coding Questions →

Practice Capgemini coding questions regularly! Focus on pseudocode for game-based assessment and basic programming for hands-on coding. Capgemini values working code that handles all test cases.

Pro Tip: Don’t underestimate the pseudocode section - it’s a significant part of the assessment. Practice tracing code outputs carefully.

Last updated: February 2026