# Top 138+ AMCAT Programming Questions With Answers 2024

AMCAT (Aspiring Minds Computer Adaptive Test) is a widely recognized employability assessment that evaluates the programming skills of job seekers. As part of the AMCAT test, candidates are often required to answer programming questions to demonstrate their proficiency in coding and problem-solving. In this blog, we will explore some common AMCAT programming questions and provide detailed answers to help you prepare effectively. Also check – Best Programming Languages / Best Cerner Interview Questions

## Amcat programming questions with answers

Question: Write a program to find the sum of all the elements in an array.

“`python

def array_sum(arr):

sum = 0

for num in arr:

sum += num

return sum

“`

Question: Implement a function to check if a string is a palindrome.

“`python

def is_palindrome(string):

return string == string[::-1]

“`

Question: Write a program to find the factorial of a number.

“`python

def factorial(n):

if n == 0 or n == 1:

return 1

else:

return n * factorial(n – 1)

“`

Question: Implement a function to find the largest element in an array.

“`python

def find_largest(arr):

max_val = arr

for num in arr:

if num > max_val:

max_val = num

return max_val

“`

Question: Write a program to check if a number is prime.

“`python

def is_prime(n):

if n <= 1:

return False

for i in range(2, int(n**0.5) + 1):

if n % i == 0:

return False

return True

“`

Question: Implement a function to reverse a string.

“`python

def reverse_string(string):

return string[::-1]

“`

Question: Write a program to sort an array in ascending order.

“`python

def sort_array(arr):

arr.sort()

return arr

“`

Question: Implement a function to count the number of vowels in a string.

“`python

def count_vowels(string):

vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]

count = 0

for char in string.lower():

if char in vowels:

count += 1

return count

“`

Question: Write a program to find the second largest element in an array.

“`python

def find_second_largest(arr):

max_val = arr

second_max = float(‘-inf’)

for num in arr:

if num > max_val:

second_max = max_val

max_val = num

elif num > second_max and num != max_val:

second_max = num

return second_max

“`

Question: Implement a function to remove duplicate elements from an array.

“`python

def remove_duplicates(arr):

return list(set(arr))

“`

Question: Write a program to reverse the order of words in a sentence.

“`python

def reverse_sentence(sentence):

words = sentence.split()

return ‘ ‘.join(words[::-1])

“`

Question: Implement a function to check if two strings are anagrams.

“`python

def is_anagram(str1, str2):

return sorted(str1) == sorted(str2)

“`

Question: Write a program to find the Fibonacci series up to a given number.

“`python

def fibonacci_series(n):

series = [0, 1]

while series[-1] < n:

series.append(series[-1] + series[-2])

return series[:-1]

“`

Question: Implement a function to find the minimum element in a rotated sorted array.

“`python

def find_minimum(arr):

low = 0

high = len(arr) – 1

while low < high:

mid = (low + high) // 2

if arr[mid] > arr[high]:

low = mid + 1

else:

high = mid

return arr[low]

“`

Question: Write a program to find the GCD (Greatest Common Divisor) of two numbers.

“`python

def gcd(a, b):

while b != 0:

temp = b

b = a % b

a = temp

return a

“`

Question: Implement a function to check if a number is a power of two.

“`python

def is_power_of_two(n):

return n > 0 and (n & (n – 1)) == 0

“`

Question: Write a program to find the sum of digits of a given number.

“`python

def sum_of_digits(n):

sum = 0

while n > 0:

digit = n % 10

sum += digit

n //= 10

return sum

“`

Question: Implement a function to reverse the order of elements in an array.

“`python

def reverse_array(arr):

return arr[::-1]

“`

Question: Write a program to check if a number is a palindrome.

“`python

def is_palindrome(n):

return str(n) == str(n)[::-1]

“`

Question: Implement a function to find the median of an array.

“`python

def find_median(arr):

arr.sort()

n = len(arr)

if n % 2 == 0:

return (arr[n // 2] + arr[(n // 2) – 1]) / 2

else:

return arr[n // 2]

“`

In conclusion, mastering programming concepts and practicing AMCAT programming questions can greatly enhance your chances of success in the AMCAT test and ultimately secure better job opportunities. Remember to understand the underlying logic behind each question and practice solving problems efficiently. With dedication, perseverance, and a solid grasp of programming fundamentals, you’ll be well-prepared to tackle any programming challenge that comes your way during the AMCAT assessment. Good luck!

## Amcat coding questions and answers for Wipro

Are you preparing for Amcat coding questions for your Wipro placement? Look no further! In this blog, we will provide you with comprehensive answers to some of the most commonly asked coding questions in the Amcat exam specifically designed for Wipro. Whether you’re a beginner or an experienced programmer, this guide will help you sharpen your coding skills and boost your confidence to ace the coding round.

Question: Write a program to find the sum of two numbers.

“`python

a = 5

b = 10

sum = a + b

print(“Sum:”, sum)

“`

Question: Write a program to check whether a number is even or odd.

“`python

num = 7

if num % 2 == 0:

print(“Even”)

else:

print(“Odd”)

“`

Question: Write a program to check whether a number is prime.

“`python

num = 17

is_prime = True

for i in range(2, int(num/2) + 1):

if num % i == 0:

is_prime = False

break

if is_prime:

print(“Prime”)

else:

print(“Not Prime”)

“`

Question: Write a program to find the factorial of a number.

“`python

num = 5

factorial = 1

for i in range(1, num+1):

factorial *= i

print(“Factorial:”, factorial)

“`

Question: Write a program to check whether a string is a palindrome.

“`python

if string == string[::-1]:

print(“Palindrome”)

else:

print(“Not Palindrome”)

“`

Question: Write a program to reverse a string.

“`python

string = “hello”

reversed_string = string[::-1]

print(“Reversed String:”, reversed_string)

“`

Question: Write a program to find the largest among three numbers.

“`python

a = 10

b = 20

c = 15

largest = max(a, b, c)

print(“Largest:”, largest)

“`

Question: Write a program to check whether a year is a leap year.

“`python

year = 2024

if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):

print(“Leap Year”)

else:

print(“Not Leap Year”)

“`

Question: Write a program to find the sum of natural numbers up to a given number.

“`python

num = 10

sum = 0

for i in range(1, num+1):

sum += i

print(“Sum:”, sum)

“`

Question: Write a program to find the Fibonacci series up to a given number.

“`python

num = 8

a, b = 0, 1

print(“Fibonacci Series:”)

while a <= num:

print(a, end=” “)

a, b = b, a+b

“`

Question: Write a program to find the GCD (Greatest Common Divisor) of two numbers.

“`python

def gcd(a, b):

while b:

a, b = b, a % b

return a

num1 = 36

num2 = 48

gcd_value = gcd(num1, num2)

print(“GCD:”, gcd_value)

“`

Question: Write a program to find the LCM (Least Common Multiple) of two numbers.

“`python

def gcd(a, b):

while b:

a, b = b, a % b

return a

def lcm(a, b):

return (a * b) // gcd(a, b)

num1 = 4

num2 = 6

lcm_value = lcm(num1, num2)

print(“LCM:”, lcm_value)

“`

Question: Write a program to check whether a given string is a palindrome ignoring case.

“`python

string = string.lower()

if string == string[::-1]:

print(“Palindrome”)

else:

print(“Not Palindrome”)

“`

Question: Write a program to find the second largest element in an array.

“`python

arr = [5, 10, 15, 20, 25]

max_num = max(arr, arr)

second_max = min(arr, arr)

for i in range(2, len(arr)):

if arr[i] > max_num:

second_max = max_num

max_num = arr[i]

elif arr[i] > second_max and arr[i] != max_num:

second_max = arr[i]

print(“Second Largest:”, second_max)

Question: Write a program to find the factorial of a number using recursion.

“`python

def factorial(n):

if n == 0:

return 1

else:

return n * factorial(n-1)

num = 6

result = factorial(num)

print(“Factorial:”, result)

“`

In conclusion, preparing for Amcat coding questions for Wipro is crucial to increase your chances of success in the placement process. By understanding the coding concepts and practicing with the provided answers, you can enhance your problem-solving abilities and stand out from the competition. Remember, consistent practice and a clear understanding of the fundamental coding concepts are key to cracking the coding round in Amcat. Best of luck on your coding journey!

## Amcat coding questions and answers for Deloitte

Amcat coding questions and answers for Deloitte provide a valuable resource for aspiring candidates looking to excel in their coding assessments. Deloitte, a renowned multinational professional services network, conducts coding assessments as part of its recruitment process. These questions are designed to evaluate candidates’ programming skills and problem-solving abilities. By preparing for these coding questions using Amcat’s comprehensive collection of answers, candidates can enhance their chances of success and showcase their technical expertise.

Question: Write a program to check if a given number is prime or not.

“`python

def is_prime(num):

if num <= 1:

return False

for i in range(2, int(num ** 0.5) + 1):

if num % i == 0:

return False

return True

“`

Question: Implement a function to reverse a string.

“`python

def reverse_string(string):

return string[::-1]

“`

Question: Write a program to find the factorial of a number.

“`python

def factorial(num):

if num == 0:

return 1

return num * factorial(num – 1)

“`

Question: Implement a function to find the nth Fibonacci number.

“`python

def fibonacci(n):

if n <= 1:

return n

a, b = 0, 1

for _ in range(n – 1):

a, b = b, a + b

return b

“`

Question: Write a program to count the number of words in a sentence.

“`python

def count_words(sentence):

words = sentence.split()

return len(words)

“`

Question: Implement a function to check if two strings are anagrams.

“`python

def are_anagrams(str1, str2):

return sorted(str1) == sorted(str2)

“`

Question: Write a program to find the maximum and minimum elements in an array.

“`python

def find_max_min(arr):

if len(arr) == 0:

return None

max_num = min_num = arr

for num in arr:

if num > max_num:

max_num = num

if num < min_num:

min_num = num

return max_num, min_num

“`

Question: Implement a function to remove duplicates from a list.

“`python

def remove_duplicates(lst):

return list(set(lst))

“`

Question: Write a program to find the sum of all even numbers in a list.

“`python

def sum_of_evens(lst):

return sum(num for num in lst if num % 2 == 0)

“`

Question: Implement a function to check if a string is a palindrome.

“`python

def is_palindrome(string):

return string == string[::-1]

“`

Question: Write a program to reverse the order of elements in an array.

“`python

def reverse_array(arr):

return arr[::-1]

“`

Question: Implement a function to find the median of a list of numbers.

“`python

def find_median(lst):

sorted_lst = sorted(lst)

n = len(sorted_lst)

if n % 2 == 1:

return sorted_lst[n // 2]

else:

return (sorted_lst[n // 2 – 1] + sorted_lst[n // 2]) / 2

“`

Question: Write a program to check if a given string is a valid palindrome ignoring non-alphanumeric characters.

“`python

def is_valid_palindrome(string):

alphanumeric_string = ”.join(ch.lower() for ch in string if ch.isalnum())

return alphanumeric_string == alphanumeric_string[::-1]

“`

Question: Implement a function to find the largest sum of any two elements in an array.

“`python

def find_largest_sum(arr):

sorted_arr = sorted(arr)

return sorted_arr[-1] + sorted_arr[-2]

“`

Question: Write a program to find the number of vowels in a string.

“`python

def count_vowels(string):

vowels = ‘aeiou’

return sum(ch in vowels for ch in string.lower())

“`

Question: Implement a function to find the GCD (Greatest Common Divisor) of two numbers.

“`python

def gcd(a, b):

while b:

a, b = b, a % b

return a

“`

Question: Write a program to check if a given number is a perfect square.