0% found this document useful (0 votes)
11 views9 pages

Accenture Coding (6-10)

Uploaded by

umas23672
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)
11 views9 pages

Accenture Coding (6-10)

Uploaded by

umas23672
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/ 9

Accenture

Topic/Course
Sub-Topic (Example: name of college)

Programs
Question 6

You are required to implement the following function.


Int OperationChoices(int c, int n, int a , int b )
The function accepts 3 positive integers ‘a’ , ‘b’ and ‘c ‘ as its arguments.
Implement the function to return.
( a+ b ) , if c=1
( a – b ) , if c=2
( a * b ) , if c=3
(a / b) , if c =4
Assumption : All operations will result in integer output.
Question 6
Example:
Input
c :1
a:12
b:16
Output:
Since ‘c’=1 , (12+16) is performed which is equal to 28 , hence 28 is returned.
Sample Input
c:2
a : 16
b : 20
Sample Output
-4
Question 7

Execute this function: 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.
Question 7

Example:
Input:
Str: apples
ch1:a
ch2:p
Output:
paales
Question 8
Write a program to create a dynamic array and sort the elements in it using
Insertion sort.

Sample Sample Output:


Input:
6 123334
123433
Question 9
Write a program to create a dynamic array and insert an element in it, in the
specified position.

Sample Sample Output:


Input:
5 1 10 2 3 4 5
12345
2 10
Question 10
Write a program to create a dynamic array and delete an element from an
array from the specified position.

Sample Sample Output:


Input:
5 1345
12345
2
THANK YOU

You might also like