# Capgemini Core CS Questions with Answers

8 previously-asked core cs questions from Capgemini's hiring process, each with the correct answer and a worked explanation. Written against the company's actual test pattern.

_Source: Astra (https://useastra.in). Updated 2026-09-05._

### 1. What is the output? int i, sum=0; for(i=1; i<=4; i++){ sum += i*i; } print(sum);

A. 30
B. 20
C. 16
D. 10

**Answer:** 30

**Explanation:** Sum of squares 1+4+9+16 = 30.

### 2. What is the output? int a=2, b=3, c; c = a++ + ++b; print(a, b, c);

A. 3 4 6
B. 3 4 5
C. 2 3 5
D. 3 3 6

**Answer:** 3 4 6

**Explanation:** a++ uses 2 then a becomes 3; ++b makes b 4 and uses 4; c = 2+4 = 6.

### 3. What is the value of x after this loop? int x=15; while(x>0){ x = x - 4; } print(x);

A. -1
B. 0
C. 3
D. 1

**Answer:** -1

**Explanation:** 15, 11, 7, 3, then -1 which stops the loop; x is -1.

### 4. What is the output? int n=6, f=1, i; for(i=1; i<=n; i=i+2){ f = f*i; } print(f);

A. 15
B. 48
C. 720
D. 9

**Answer:** 15

**Explanation:** i takes 1, 3, 5, so f = 1*3*5 = 15.

### 5. What is the output? int arr[5]={10,20,30,40,50}; int s=0,i; for(i=0; i<5; i+=2){ s += arr[i]; } print(s);

A. 90
B. 60
C. 150
D. 100

**Answer:** 90

**Explanation:** It adds arr[0], arr[2], arr[4] = 10+30+50 = 90.

### 6. What is the output of func(5)? func(int n){ if(n==0) return 0; return n + func(n-1); }

A. 15
B. 5
C. 10
D. 120

**Answer:** 15

**Explanation:** This sums 5+4+3+2+1+0 = 15.

### 7. What is the value of b? int a=5; int b = (a>3) ? ((a<10) ? 1 : 2) : 3; print(b);

A. 1
B. 2
C. 3
D. 5

**Answer:** 1

**Explanation:** a>3 is true and a<10 is true, so the innermost value 1 is selected.

### 8. What is the output? int x=1, i; for(i=0; i<3; i++){ x = x*2; } print(x);

A. 8
B. 6
C. 3
D. 16

**Answer:** 8

**Explanation:** x doubles three times: 1, 2, 4, 8.

More Capgemini preparation, including the full recruitment process: https://useastra.in/campus/capgemini
