Accenture Coding Assessment QUestions , SQL , Web

Accenture Coding Assessment | Coding Question Solution

Exam Questions & Solutions

Detailed breakdown and working code solutions for Coding, Web, and SQL assessment questions.

Problem Statement

Sum of Digits Until Single Digit (Add Digits)

Question Details: Given a number (e.g., 38), continuously add all its digits until the result is a single digit.
Example: 383 + 8 = 111 + 1 = 2. Output = 2.

Java Solution

public class Main { public static int addDigits(int num) { while (num >= 10) { int sum = 0; while (num > 0) { sum += num % 10; num /= 10; } num = sum; } return num; } public static void main(String[] args) { System.out.println(“Output: ” + addDigits(38)); // Output: 2 } }

Python Solution

def add_digits(num: int) -> int: while num >= 10: num = sum(int(digit) for digit in str(num)) return num print(“Output:”, add_digits(38)) # Output: 2
HTML & CSS Requirement

Target Specific Input Types and Apply Padding

Question Details: Target an HTML input element specifically by its type attribute in CSS and apply custom padding styling.

HTML Structure

<!– Text Input Element –> <input type=”text” class=”custom-input” placeholder=”Enter text here…”>

CSS Solution

/* Target specific input type using attribute selector */ input[type=”text”] { padding: 16px 20px; /* Applies vertical and horizontal padding */ border: 2px solid #000033; border-radius: 6px; font-size: 14px; }
JavaScript Validation

Password Match & Validation Logic

Question Details: On clicking submit:
1. If empty, display “Password is not there”.
2. If passwords match, display the matched password.
3. If passwords differ, display “Wrong password” using textContent.

Live Interactive Test:

JavaScript Solution Code

function validatePassword() { const password = document.getElementById(“passInput”).value.trim(); const confirmPassword = document.getElementById(“confirmPassInput”).value.trim(); const resultMsg = document.getElementById(“resultMsg”); if (password === “” || confirmPassword === “”) { resultMsg.textContent = “Password is not there”; resultMsg.style.color = “#dc2626”; } else if (password === confirmPassword) { resultMsg.textContent = “Password matched: ” + password; resultMsg.style.color = “#16a34a”; } else { resultMsg.textContent = “Wrong password”; resultMsg.style.color = “#dc2626”; } }
Database Query

3-Table LEFT JOIN Query

Question Details: Join three tables using LEFT JOIN to extract student details along with course and assessment information.

SQL Query Solution

SELECT s.student_id, s.student_name, c.course_name, a.score, a.status FROM students s LEFT JOIN enrollments e ON s.student_id = e.student_id LEFT JOIN courses c ON e.course_id = c.course_id LEFT JOIN assessments a ON s.student_id = a.student_id;