# Accenture Coding Interview Questions

### Question:8

(Asked in Accenture OnCampus 12 Aug 2021, Slot 2)

N-base notation is a system for writing numbers that uses only n different symbols, This symbols are the first n symbols from the given notation list(Including the symbol for o) Decimal to n base notation are (0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A,11:B and so on upto 35:Z)

Char* DectoNBase(int n, int num):

The function accept positive integer n and num Implement the function to calculate the n-base equivalent of num and return the same as a string

Steps:

• Divide the decimal number by n,Treat the division as the integer division
• Write the the remainder (in n-base notation)
• Divide the quotient again by n, Treat the division as integer division
• Repeat step 2 and 3 until the quotient is 0
• The n-base value is the sequence of the remainders from last to first
• Assumption:

1 < n < = 36

Example

Input

n: 12

num: 718

Output

Explanation

Sample Input

n: 21

num: 5678

Sample Output

## Rules for Accenture Coding Questions Section

• Two questions will be asked. You’ve to solve both the questions in 45 minutes.
• You must start your code from scratch.
• The Coding section is divided into two, first for writing the code and the other for the output. So you should write the whole program.
• Errors are clearly displayed.
• ### Question:11

(Asked in Accenture Offcampus 1 Aug 2021, Slot 3)

Problem Statement

Void *ReplaceCharacter(Char str[], int n, char ch1, char ch2);

The function accepts a string ‘ str’ of length n and two characters ‘ch1’ and ‘ch2’ as its arguments . Implement the function to modify and return the string ‘ str’ in such a way that all occurrences of ‘ch1’ in original string are replaced by ‘ch2’ and all occurrences of ‘ch2’ in original string are replaced by ‘ch1’.

Assumption: String Contains only lower-case alphabetical letters.

Note:

• Return null if string is null.
• If both characters are not present in string or both of them are same , then return the string unchanged.
• Example:

Explanation:

‘A’ in original string is replaced with ‘p’ and ‘p’ in original string is replaced with ‘a’, thus output is paales.

### Question:9

(Asked in Accenture Offcampus 1 Aug 2021, Slot 1)

Implement the following functions.a

The function accepts a string “str” of length ‘n’, that contains alphabets and hyphens (-). Implement the function to move all hyphens(-) in the string to the front of the given string.

NOTE:- Return null if str is null.

Example :-

Explanation:-

The string “Move-Hyphens -to-front” has 3 hyphens (-), which are moved to the front of the string, this output is “— MoveHyphen”

Sample Input

Sample Output-

### Question:13

(Asked in Accenture Offcampus 2 Aug 2021, Slot 2)

Problem Statement

Int MaxExponents (int a , int b);

You have to find and return the number between ‘a’ and ‘b’ ( range inclusive on both ends) which has the maximum exponent of 2.

The algorithm to find the number with maximum exponent of 2 between the given range is

• Loop between ‘a’ and ‘b’. Let the looping variable be ‘i’.
• Find the exponent (power) of 2 for each ‘i’ and store the number with maximum exponent of 2 so faqrd in a variable , let say ‘max’. Set ‘max’ to ‘i’ only if ‘i’ has more exponent of 2 than ‘max’.
• Return ‘max’.
• Assumption: a

Note: If two or more numbers in the range have the same exponents of 2 , return the small number.

Example

Explanation:

Exponents of 2 in:

Hence maximum exponent if two is of 8.

## Accenture Coding Questions

In Accenture there will be 2 coding questions that you have to solve in 45 minutes. In the Accenture Coding Round ,you can write coding using in these preferred language:-

The difficulty level of the questions are high. You have to practice alot to get good score in the accenture coding Questions.

There will be total of 2 Questions asked in the Accenture Coding Round. For successfully clearing the Coding Round, Students need to have 1 Complete Output and 1 Partial Output.

Accenture Coding Round No of Questions Min. Selection Criteria
Coding Questions 2 One Complete Output One Partial Output
• There are two question for 45 minutes.
• We must start our code from the scratch.
• The coding platform is divided into two, one for writing the code and other for output. We should write the whole program.
• The errors are clearly mentioned.
• One Partial and One Complete Output is required for clearing the round.
•  Total number of Questions 2 Question Total Time Duration 45 minutes Type of Test Non- Adaptive Negative Marking No