AMCAT Coding Questions and Answers PDF for Test

AMCAT Coding Questions are of moderate to high difficulty and the Languages that you’re allowed to code in are C, C++, C# and Java. Below you will find questions that you must practice before giving any AMCAT Exam.

  1. Number of Questions – 2
    1. Generally one easy
    2. One medium difficulty

Program to remove Duplicate Element of an Array


#include
<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,j,k,n;
clrscr();
 
printf("\nEnter array size : ");
scanf("%d",&n);
 
printf("\nEnter %d array element : ",n);
for(i=0;i< n;i++)
scanf("%d",&a[i]);
 
printf("\nOriginal array is : ");
for(i=0;i< n;i++)
printf(" %d",a[i]);
 
printf("\nNew array is : ");
for(i=0;i< n;i++)
{
for(j=i+1;j< n;)
{
if(a[j]==a[i])
{
for(k=j;k< n;k++)
a[k]=a[k+1];
n--;
}
else
j++;
}
}
 
for(i=0;i< n;i++)
printf("%d ",a[i]);
getch();
}

Addition of the all elements of the array list

#include<stdio.h>

#include<conio.h>

void main()

{
int a[5],i = 5,sum=0;
printf("Enter the elements of list \n");

int j;

for(j=0;j<i;j++)

scanf("%d",&a[j]);

fflush(stdin);

printf("The list elements are \n");


for(j=0;j<i;j++)

printf("%d ",a[j]);

printf("\n");

for(i=0;i<5;i++)

{

sum+=a[i];

}

printf("The sum of the elements of the list is %d\n",sum);

}

Decimal to Hexadecimal

Hexadecimal number system: It is base 16 number system which uses the digits from 0 to 9 and A, B, C, D, E, F.

Decimal number system:
It is base 10 number system which uses the digits from 0 to 9

Decimal to hexadecimal conversion method:

Following steps describe how to convert decimal to hexadecimal

Step 1: Divide the original decimal number by 16
Step 2: Divide the quotient by 16
Step 3: Repeat the step 2 until we get quotient equal to zero.

Equivalent binary number would be remainders of each step in the reverse order.

Decimal to hexadecimal conversion example:

For example we want to convert decimal number 900 in the hexadecimal.

Step 1: 900 / 16 Remainder : 4 , Quotient : 56
Step 2: 56 / 16 Remainder : 8 , Quotient : 3
Step 3: 3 / 16 Remainder : 3 , Quotient : 0

So equivalent hexadecimal number is: 384
That is (900)10 = (384)16

#include<stdio.h>
int main() {
long int decimalNumber,remainder,quotient;
int i=1,j,temp;
char hexadecimalNumber[100];
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0) {
temp = quotient % 16;
//To convert integer into character
if( temp < 10)
temp =temp + 48; else
temp = temp + 55;
hexadecimalNumber[i++]= temp;
quotient = quotient / 16;
}
printf("Equivalent hexadecimal value of decimal number %d: ",decimalNumber);
for (j = i -1 ;j> 0;j--)
printf("%c",hexadecimalNumber[j]);
return 0;
}

frequency of odd numbers and even numbers in matrix

#include

void main () {

static int ma[10][10];

int i,j,m,n,even=0,odd=0;

printf ("Enter the order ofthe matrix \n");

scanf ("%d %d",&m,&n);

printf ("Enter the coefficients if matrix \n");

for (i=0;i<m;++i) {

for (j=0;j<n;++j) {

scanf ("%d", &ma[i][j]);

if ((ma[i][j]%2) == 0) {

++even;

} else

++odd;

}

}

printf ("The given matrix is\n");

for (i=0;i<m;++i) {

for (j=0;j<n;++j) {

printf (" %d",ma[i][j]);

}

printf ("\n");

}

printf ("\nThe frequency of occurance of odd number = %d\n",odd);

printf ("The frequency of occurance of even number = %d\n",even);

}

decimal to octal converter

Octal number system: It is base 8 number system which uses the digits from 0 to 7.

Decimal number system:
It is base 10 number system which uses the digits from 0 to 9

Decimal to octal conversion method:

Step 1: Divide the original decimal number by 8
Step 2: Divide the quotient by 8
Step3: Repeat the step 2 until we get quotient equal to zero.

Result octal number would be remainders of each step in the reverse order.

Decimal to octal conversion with example:

For example we want to convert decimal number 525 in the octal.

Step 1: 525 / 8 Remainder : 5 , Quotient : 65
Step 2: 65 / 8 Remainder : 1 , Quotient : 8
Step 3: 8 / 8 Remainder : 0 , Quotient : 1
Step 4: 1 / 8 Remainder : 1 , Quotient : 0

So equivalent octal number is: 1015
That is (525)10 = (1015)8

#include
int main() {
long int decimalNumber,remainder,quotient;
int octalNumber[100],i=1,j;
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0) {
octalNumber[i++]= quotient % 8;
quotient = quotient / 8;
}
printf("Equivalent octal value of decimal number %d: ",decimalNumber);
for (j = i -1 ;j> 0;j--)
printf("%d",octalNumber[j]);
return 0;
}

remove duplicate element in an array

#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,j,k,n;
clrscr();

printf("\nEnter array size : ");
scanf("%d",&n);

printf("\nEnter %d array element : ",n);
for(i=0;i< n;i++)
scanf("%d",&a[i]);

printf("\nOriginal array is : ");
for(i=0;i< n;i++)
printf(" %d",a[i]);

printf("\nNew array is : ");
for(i=0;i< n;i++)
{
for(j=i+1;j< n;)
{
if(a[j]==a[i])
{
for(k=j;k< n;k++)
a[k]=a[k+1];
n--;
}
else
j++;
}
}

for(i=0;i< n;i++)
printf("%d ",a[i]);
getch();
}

AMCAT Coding Questions in Java

AMCAT Coding QuestionsAsked in JavaAsked in CAsked in C++
Pattern based QuestionsYesYesYes
Logical thinkingYesYesYes
Mathematical OperationsYesYesYes
Data StructuresNoNoNo
MatricesYesYesYes