# Accenture Core CS Questions with Answers

8 previously-asked core cs questions from Accenture'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 a=10, b=20; a=a+b; b=a-b; a=a-b; print(a, b);

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

**Answer:** 20 10

**Explanation:** This is the classic swap without a temporary variable, so a and b are exchanged.

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

A. 15
B. 10
C. 20
D. 25

**Answer:** 15

**Explanation:** Sum of 1 to 5 = 15.

### 3. What does this print? int i=0; while(i<3){ print(i); i++; }

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

**Answer:** 0 1 2

**Explanation:** The loop prints i for i = 0, 1, 2 and stops when i becomes 3.

### 4. What is the output of f(4)? function f(n){ if(n<=1) return 1; return n*f(n-1); }

A. 24
B. 12
C. 4
D. 16

**Answer:** 24

**Explanation:** This computes factorial: 4*3*2*1 = 24.

### 5. Given arr = {3, 1, 4, 1, 5}, what is arr[2] + arr[4]? (0-based indexing)

A. 9
B. 8
C. 6
D. 10

**Answer:** 9

**Explanation:** arr[2]=4 and arr[4]=5, so 4+5 = 9.

### 6. What is printed? int x=7; if(x%2==0) print("even"); else print("odd");

A. odd
B. even
C. 7
D. error

**Answer:** odd

**Explanation:** 7 is not divisible by 2, so the else branch runs.

### 7. Which data structure follows the First In First Out (FIFO) order?

A. Queue
B. Stack
C. Tree
D. Graph

**Answer:** Queue

**Explanation:** A queue inserts at the rear and removes from the front, giving FIFO order.

### 8. Which OOP concept allows a class to acquire the properties and behaviour of another class?

A. Inheritance
B. Encapsulation
C. Polymorphism
D. Abstraction

**Answer:** Inheritance

**Explanation:** Inheritance lets a child class reuse the members of a parent class.

More Accenture preparation, including the full recruitment process: https://useastra.in/campus/accenture
