Amcat Automata Questions with Solutions 2019 | Faceprep

AMCAT Automata questions with solutions are discussed here in detail. AMCAT conducts AMCAT Automata test to evaluate the programming skills of students. This test evaluates candidates skills based on their knowledge of data structures, algorithms, memory allocation etc. Hence a lot of companies determine the candidates potential on the basis of their score in AMCAT exam.

AMCAT Automata Test Details

The AMCAT Automata test consists of 2 questions. One of these questions will be easy and the other will be hard to solve. The candidates should write the program in the editor, compile it and run test cases in the environment of Automata 2.0 software provided. The candidate has the freedom to choose the programming language to code in as the compiler supports wide range of programming languages like Java, C, C++ and more.

AMCAT Automata questions – Evaluation of Codes

The code written by the candidate is evaluated based on the following:

• Whether the code runs for basic, advanced, and boundary test cases.
• Whether the code industry-compatible.
• The complexity of the code.
• Warnings, runtime and timeout errors generated during the compilation.
• Time taken to submit the final code.

Recently asked AMCAT Automata Questions

Some of the recently asked AMCAT Automata questions with their answers are discussed here. These questions are of easy and hard difficulty levels.

1 – AMCAT automata questions

Find the number of all possible triplets in the array that can form the triangle (condition is a + b > c).

#include"stdio.h"
int arr, n, n1, n2, i, j, k;
int a,b,c;
int main()
{
scanf(“%d”,&n);
for(i=0;i<n;i++)
scanf(“%d”,&arr[i]);
for(i=0;i<n-2;i++)
{
a=arr[i];
for(j=i+1;j<n-1;j++)
{
b=arr[j];
for(k=j+1;k<n;k++)
{
c=arr[k];
if( ((a + b)>c) && ((a + c)>b) && ((b + c)>a) )
{
printf(“%d  %d  %d  “,a,b,c);
printf(“Yes\n”);
}
else
{
printf(“%d  %d  %d  “,a,b,c);
printf(“No\n”);
}
}
}
}
return 0;
}

2 – AMCAT automata questions

Print all the prime numbers which are below the given number separated by comma.

Input: 50

#include"stdio.h"
int main()
{
int n,i,j,ct=0;
scanf(“%d”,&n);
for(i=2;i<=n;i++)
{
ct=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{ ct=1; break; }
}
if(ct==0)
{
if(i>2)
printf(“, “);
printf(“%d”,i);
}
}
return 0;
}

Output: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47

Similar questions with solutions in all languages:

3 – AMCAT automata questions

Program to find the GCD of two Integers. Click here to view solutions in all languages.

#include”stdio.h”
int main()
{
int  m, n, i, gcd;
scanf(“%d %d”, &m, &n);
for(i=1; i <=m && i <= n; ++i)
{
// Checks if i is factor of both integers
if(m%i==0 && n%i==0)
gcd = i;
}
printf(“ %d”, gcd);
return 0;
}

4 – AMCAT automata questions

Program to find out the sum of digits of a given number. Click here for a more detailed explanation and solution in all languages.

#include “stdio.h”

void main()
{
long n, t, digit;
int sum = 0;
scanf(“%ld”, &n);
t  = n;
while (n > 0)
{
digit = n % 10;
sum = sum + digit;
n /= 10;
}
printf(“%d”, sum);
}

5 – AMCAT automata questions

Print the pattern if the input is 5

1
3*2
4*5*6
10*9*8*7
11*12*13*14*15

#include ”stdio.h”
int main()
{
int i, j, k, l=1, N, d, r, count=0;
scanf(“%d”, &N);
for(i=1; i<=N; i++)
{
k=1;
d=i%2;
r=l+i-1;
for(j=0;j<i;j++)
{
if(d==0)
{
printf(“%d”,r);
r–;
if(k<i)
{
printf(“*”);
k=k+1;
}
l++;
continue;
}
printf(“%d”,l);
l++;
if(k<i)
{
printf(“*”);
k=k+1;
}
}
printf(“\n”);
}
return 0;
}

Similar questions with solutions in all languages:

6 – AMCAT automata questions

Mooshak the mouse has been placed in a maze. There is a huge chunk of cheese somewhere in the maze. The maze is represented as a two-dimensional array of integers, where 0 represents walls.1 represents paths where Mooshak can move and 9 represents the huge chunk of cheese. Mooshak starts in the top left corner at 0.

Write a method is Path of class Maze Path to determine if Mooshak can reach the huge chunk of cheese. The input to is Path consists of a two-dimensional array and for the maze matrix. the method should return 1 if there is a path from Mooshak to the cheese and 0 if not Mooshak is not allowed to leave the maze or climb on walls.

EX: 8 by 8(8*8) matrix maze where Mooshak can get the cheese.

1 0 1 1 1 0 0 1
1 0 0 0 1 1 1 1
1 0 0 0 0 0 0 0
1 0 1 0 9 0 1 1
1 1 1 0 1 0 0 1
1 0 1 0 1 1 0 1
1 0 0 0 0 1 0 1
1 1 1 1 1 1 1 1

Test Cases:

Test Case 1:
Input: [[0,0,0],[9,1,1],[0,1,1]]
Expected return value: 0

Explanation:
The piece of cheese is placed at(1,0) on the grid Mooshak can move from (0,0) to (1,0) to reach it or can move from (0,0) to (0,1) to (1,1) to (1,0)
#include”stdlib.h”
#include”stdio.h”
int path(int maze);
int main()
{
int i,j,maze, result=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
scanf (“%d”, &maze[i][j]);
}
printf(“input\n”);
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
printf(“%d “,maze[i][j]);
}
printf(“\n”);
}
printf(“%d”, path(maze));
return 0;
}
int path(int m)
{ for(static int i=0;i<3;i++)
{ for(int j=0;j<3;j++)
{ if((m[i][j]==1))
int path(m);
if(m[i][j]==0)
return 0;
if(m[i][j]==9)
return 1;
}
}
}

7 – AMCAT automata questions

Program to print all distinct elements of given input arrays. Also print the total of the distinct elements.

Input:

Arr1 = {1,2,3,4,5}
Arr 2 = {2,6,8,10}

#include”stdio.h”
int Not_common (int *arr1, int *arr2, int l1, int l2)
{
int count =0, flag1, i, j;
for(i=0; i<l1; i++)
{
flag1=0;
for(j=0; j<l2; j++)
{
if(arr1[i] == arr2[j])
{
flag1=1;  break;
}}
if(flag1 ==0)
{
count++;
printf(“%d,”, arr1[i]);
}
}
for(i=0; i<l2; i++)
{
flag1=0;
for(j=0; j<l1; j++)
{
if(arr2[i] == arr1[j])
{
flag1=1;
break;
}}
if(flag1 ==0)
{
count++;
printf(“%d,”, arr2[i]);
}}
return count;
}
int main()
{
int len1=3,len2=3, result, i, j;
int arr1,arr2;
scanf(“%d %d”, &len1, &len2);
for(i=0; i<len1; i++)
scanf(“%d”, &arr1[i]);
for(i=0; i<len2; i++)
scanf(“%d”, &arr2[i]);
result = Not_common (arr1,arr2,len1,len2);
printf(“\n %d”, result);
return 0;
}

Output: {1,3,4,5,6,8,10} total is 7

8 – AMCAT automata questions

Swap corresponding elements of the array.

Traversing the array and swapping i and i + 1 element.

#include
using namespace std;
void swap(int *p1, int *p2){
//Function swaps two element
int t;
t = *p1;
*p1 = *p2;
*p2 = t;
}
int * swapArr(int *arr, int len){
int *t;
for(int i = 0; i < len - 1; i++){
//Sends a pointer to two coresponding elements
swap(arr + i, arr + i + 1);
}
return arr;
}
int main(){
int n, *p;
//Input size of array
cin >> n;
int arr[n];
for(int i = 0; i < n; i++){
cin >> arr[i];
}
//p gets the pointer to array after swapping
p = swapArr(arr, n);
cout << endl;
for(int i = 0; i < n; i++){
cout << *(arr + i) << " ";
}
cout << endl;
return 0;
}

9 – AMCAT automata questions

Print the below pattern
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Click here for a more detailed explanation and solution in all languages.

#include
using namespace std;
void printPascal(int n)
{
int x = n;
for (int line = 1; line <= n; line++)
{
for(int j = x; j > 0; j--)
cout << " ";
x--;
int C = 1;
for (int i = 1; i <= line; i++)
{
cout << C << " ";
C = C * (line - i) / i;
}
cout << endl;
}
}
int main()
{
int x;
//Input number of rows
cin >> x;
printPascal(x);
return 0;
}

10 – AMCAT automata questions

Print the below pattern where Input n=6.

Output
1111112
3222222
3333334
5444444
5555556
7666666

#include
using namespace std;
void patternprint(int);
int main()
{
int num;
cin>>num;
patternprint(num);
return 0;
}
void patternprint(int num)
{
int x = 1;
for( int i = 0 ; i < num ; i++ )
{
if(i % 2 == 0)
{
for( int j = 1 ; j <= num ; j++)
cout << x;
cout << x + 1;
}
else
{
cout << x + 1;
for( int j = 1 ; j <= num ; j++)
cout << x;
}
cout << "\n";
x++;
}
}

Also check :

Amcat automata test is a programming test to evaluate a candidates programming proficiency. It not only evaluates correctness but also code quality & efficiency in execution.

There is no defined syllabus for Amcat Automata test. This test basically evaluates the coding efficiency of candidates. So one needs to have the knowledge of C, advanced C concepts and Data structures to crack this test.

Have a look at the above mentioned programming questions to know get a rough idea of the syllabus.

2 questions will be asked in this section. One of the questions is likely to be easy, while the other might be of higher difficulty level.

Automata Pro is an assessment similar to Amcat automata, which evaluates the actual programming skills of a candidate, giving the candidate an opportunity to write the program in an editor, compile and run test cases, all in the assessment environment itself.

Summary
Date of Review
Article Title
Amcat Automata Coding Questions
Rating
5     