0% found this document useful (0 votes)
152 views

Accenture Codingquestions PDF

The document contains questions related to writing functions to validate passwords based on certain criteria, perform binary operations on strings, calculate the difference between sums of integers divisible and not divisible by a given number, find the largest number by permuting digits of an integer array, count number of carries when adding two numbers, and determine if a number is autobiographical based on the frequencies of its digits.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views

Accenture Codingquestions PDF

The document contains questions related to writing functions to validate passwords based on certain criteria, perform binary operations on strings, calculate the difference between sums of integers divisible and not divisible by a given number, find the largest number by permuting digits of an integer array, count number of carries when adding two numbers, and determine if a number is autobiographical based on the frequencies of its digits.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Question 1

Write a function CheckPassword(str) which will accept the string as an


argument or parameter and validates the password. It will return 1 if the
conditions are satisfied else it’ll return 0?

The password is valid if it satisfies the below conditions:

It should contain at least 4 characters.


At least 1 numeric digit should be present.
At least 1 Capital letter should be there.
Password should not contain space or slash.
The starting character should not be a number.
Question 1

Input:
bB1_89
Output:
Input:
1 aA_1
Output:
Input: 1
abc_@89 Input:
Output: Abc @89
0 Output:
0
Question 2

Write a function CalculateBinaryOperations(str) that accepts the string as


an argument or parameter. The string should contains the binary numbers
with their operators OR, AND, and XOR?

•A Means the AND Operation.


•B Means the OR Operation.
•C Means the XOR Operation.
By scanning the given string from left to right you’ve to calculate the string
and by taking one operator at a time then return the desired output.
Question 2

Conditions:
•The priority of the operator is not required.
•The length of the string is always Odd.
•If the length of the string is null then return -1.

Sample Test Case:


Input:
1C0C1C1A0B1
Output:
1
Question 2

Explanation:
The entered input string is 1 XOR 0 XOR 1 XOR 1 AND 0 OR 1.
Now calculate the string without an operator priority and scan the string
characters from left to right. Now calculate the result and return the desired
output.
Note: This will convert the char into the num (char – ‘0’) in the c++ language
Question 3

Write a function differenceofSum(b,n) which will take two integers as an


argument. You’ve to obtain the total of all the integers ranging from 1 to n
(both inclusive) that are not divisible by b. You should also return the
distinction between the sum of the integers which are not divisible by b
with the sum of the integers divisible by b?

Consider: a and b are greater than 0. i.e a>0 and b>0. And their sum should
lies between the integral range.
Question 3

Sample Test Case 1:


Input:
b = 6 and n = 30
Output:
285
Explanation:
The integers that are divisible by 6 are 6, 12, 18, 24, and 30 and their sum is
90. The integers that are not divisible by 6 are 1, 2, 3, 4, 5, 7, 8, 9, 10, 11,
13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 25, 26, 27, 28 and 29. And their
addition is 375.
The difference between them is (375 – 90) = 285.
Question 3

Sample Test Case 2:


Input:
a = 10
b=3
Output:
19
Question 4
Write a Program that accepts the integer array of length ‘size’ and finds
the largest number that can be formed by permutation .

Assumption : The order of the numbers might need rearrangement to


make the largest possible number.

Sample input:
34795864
Sample output:
98765443
Question 5
Execute this function: Int Numberofcarry(Integer num 1, Integer num 2)
When the sum of the digits exceeds a total of 9, a carry digit is added to
the right-left of the digit.

num1, num2 > = 0


Example: If Input is num1 = 451, num2 = 349 then output will be 2

Example : num1=999, num2=999 then output will be 3


Question 6
A number is said to be an Autobiographical number, if the number’s first
digit represents the number of 0 available in the given number, the
second number represents the number of 1 present in the given number,
the third number represents the number of 2 present in the given
number and so on.

In simple terms, if the given number’s digits from left to right represent
the frequency of 0, 1, 2, 3, 4.... N respectively present in the given
number then that number is known as Autobiographical number.

Some examples of Autobiographical numbers are: 1210, 2020, 21200,


3211000, 42101000 ... etc.
Question 6
Some examples of Autobiographical numbers are: 1210, 2020, 21200,
3211000, 42101000 ... etc.
Instance-1
Input number is 1210.
Let’s check it by using the logic of Autobiographical numbers.
Number of zeros available in the given number is = 1. And the first digit
is also 1.
Question 6
Number of one’s available in the given number is= 2. And the second
digit is also 2.
Number of two available in the given number is= 1. And the third digit is
also 1.
Number of three’s available in the given number is= 0. And the fourth
digit is also 0.
As we notice here by arranging all those digits, we will get the same
original number.
Hence, 1210 is an Autobiographical number

You might also like