AMCAT Coding Questions

AMCAT Automata Program is the most important section in AMCAT Programming Questions with Solutions topic, AMCAT Java Programming Questions, AMCAT Automata Questions PDF for AMCAT Programming Test, AMCAT Java Questions and C++ Questions with C Questions for Practice.

  • Whether the code runs for basic, advanced, and boundary test cases.
  • Whether the code industry-compatible.
  • Complexity of the code.
  • Warnings, run time and time out errors generated during the compilation.
  • Time taken to submit the final code.

AMCAT Automata Section for AMCAT Programming Questions are of varying difficulty for some companies like wipro and cognizant, it will be relatively easier than for Amazon. Though AMCAT automata question the pattern has been constant since the last few years, but the questions are a little tricky to solve. Below we have provided few AMCAT coding questions for the new Pattern of the exam.

  • Number of Questions – 2 Questions
  • Difficulty Level – 1 Easy + 1 Medium
  • Cut-off – Solve 1 question completely or 2 partial outputs
Watch our all of our YouTube videos series below on AMCAT Pattern Printing preparation and you will be able to solve any AMCAT Pattern questions easily also, subscribe our Youtube Channel as well.

AMCAT Automata Programming Questions Pattern

AMCAT automata section, is an additional topic that many companies ask for while giving aspiring minds test. Companies like Wipro, CTS etc use use this section as the last section of their written test paper.

AMCAT Automata Questions with Answers

AMCAT Automata Questions and AnswersDifficultyProbability of askingType
Pattern based QuestionsEasy – Medium80%non automata
String based questionsMedium30%automata
GCD Based QuestionsMedium50%automata
Matrix based QuestionsMedium – Hard40%automata

In AMCAT programming paper that are asked one is very easy level and one is moderate difficulty Level.

Here are list of programming languages that you can use

  • AMCAT Programming and Automata Questions Java
  • AMCAT Programming and Automata Questions C
  • AMCAT Programming and Automata Questions C++

AMCAT Coding Questions with Answers based FAQ’s

Ques. What is the level of difficulty for amcat coding questions?

Ans. You will be getting 2 questions one easy and one tough for AMCAT Programming Section in Automata.

Ques. Are there marks for getting Partial Output?

Ans. Yes, even if you dont know the solutions please make the functions accepting parameters and fetch input from the users, you will get some marks for this, don’t leave it blank.

Most Important 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}

In C Language

#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[10],arr2[10];

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

Program to remove all vowels from a given string using pointers

Input:

PrepInsta

In C using switchcase

#include <stdio.h>

#include <string.h>




int check_vowel(char);

int main()

{

  char s[100], t[100];

  int i, j = 0;

  scanf("%[^\n]s",s);

  for(i = 0; s[i] != '\0'; i++) {

    if(check_vowel(s[i]) == 0) {        

 t[j] = s[i];

      j++;

    }

  }

  t[j] = '\0';

  strcpy(s, t);    

  printf("%s\n", s);

  return 0;

}

  

int check_vowel(char c)

{

  switch(c) {

    case 'a':

    case 'A':

    case 'e':

    case 'E':

    case 'i':

    case 'I':

    case 'o':

    case 'O':

    case 'u':

    case 'U':

      return 1;

    default:

      return 0;

  }

}

In C using pointers

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define TRUE 1

#define FALSE 0

int check_vowel(char);

int main()

{

   char string[100], *temp, *pointer, ch, *start;

   gets(string);

   temp = string;

   pointer = (char*)malloc(100);

  if( pointer == NULL )

   {

      exit(EXIT_FAILURE);

   }

start = pointer;

   while(*temp)

   {

      ch = *temp;

      if ( !check_vowel(ch) )

      {

         *pointer = ch;

         pointer++;

      }

      temp++;

   }

   *pointer = '\0';

   pointer = start;

   strcpy(string, pointer);

   free(pointer);

   printf("%s\n", string);

   return 0;

}

int check_vowel(char a)

{

   if ( a >= 'A' && a <= 'Z' )

      a = a + 'a' - 'A';

   if ( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')

      return TRUE;

   return FALSE;

}

Output: eia

Find the occurrence of a substring in a parent string

Input:

aAbcDefabcAdf

Substring : abc

In C

#include <stdio.h>

#include <string.h>

char str[100], sub[100];

int count = 0, count1 = 0;

int main()

{

int i, j, l, len1, len2;

printf("\nEnter a string : ");

scanf("%[^\n]s", str);

len1 = strlen(str);

printf("\nEnter a substring : ");

scanf(" %[^\n]s", sub);

len2 = strlen(sub);

for (i = 0; i < len1;)

{

j = 0,  count = 0;

while ((str[i] == sub[j]))

{

count++;   i++;  j++;

}

if (count == len2)

{            count1++;                                   

count = 0;

}

}

printf(“%d”, count1);

return 0; }

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

In C

#include <stdio.h>
int a[100];
int n,n1,n2;
int i,j,k;
int p,q,r;

int main(void) 
{    
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    for(i=0;i<n-2;i++)
    {   
        p=a[i];
        for(j=i+1;j<n-1;j++)
        {
        q=a[j];
      for(k=j+1;k<n;k++)
            {
            r=a[k];
            if( ((p+q)>r) && ((p+r)>q) && ((q+r)>p) )
            {
            printf("%d  %d  %d  ",p,q,r);
            printf("Yes\n");
            }
            else
            {
            printf("%d  %d  %d  ",p,q,r);
            printf("No\n");
            }        
            }
        }
    }
    return 0;
}

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

Input: 50

In C

#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);

         }

     }

}

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

Write a program to find the GCD of two Integers.

In C

#include,stdio.h>
int main() 

int n1, n2, i, gcd; 
printf("Enter two integers: "); 
scanf("%d %d", &n1, &n2); 
for(i=1; i <= n1 && i <= n2; ++i) 

// Checks if i is factor of both integers 
if(n1%i==0 && n2%i==0) 
gcd = i; 

printf("G.C.D of %d and %d is %d", n1, n2, gcd); 
return 0; 
}

Write a program to reverse a string

Input: PrepInsta

In C

 #include <stdio.h>

 #include <string.h>

 void reverse(char [], int, int);

 int main()

 {

     char str1[100];

     int size;

     scanf("%[^n]s", str1);

     size = strlen(str1);

     reverse(str1, 0, size - 1);

     printf("%s", str1);

     return 0;

 }

void reverse(char str1[], int index, int size)

 {   char temp;

     temp = str1[index];

     str1[index] = str1[size - index];

     str1[size - index] = temp;

     if (index == size / 2)

     {

         return;

     }

     reverse(str1, index + 1, size);

 }

Output: atsnIperP

Write a program to swap two numbers without using third variable,

In C

#include<stdio.h> 
intmain()     
{     
inta=10, b=20;       
printf("Before swap a=%d b=%d",a,b);       
a=a+b;//a=30 (10+20)   
b=a-b;//b=10 (30-20)   
a=a-b;//a=20 (30-10)   
printf("\nAfter swap a=%d b=%d",a,b);     
return0;   
}   

Write a program to print Fibonacci series of given range.

In C

#include <stdio.h> 
#include <conio.h> 
void main() 

long a=1 ,b=1 , c ; 
int i , n ; 
printf("Enter n: ") ; 
scanf("%d" , &n) ; 
printf("Fibonacci series is as shown: \n") ; 
if(n==1) 
printf("% ld \n %ld \n" , a , b) ; 
else if(n>1) 

printf("% ld \n %ld \n" , a , b) ; 
c=a+b ; 
do 

printf(" %ld \n" , c) ; 
a=b ; 
b=c ; 
c=a+b ; 

while(c<=n) ; 

}

Write a function to return a sorted array after merging two unsorted arrays, the parameters will be two integer pointers for referencing arrays and two int variable, the length of arrays (Hint: use malloc() to allocate memory for 3rd array):

In C

#include <stdio.h>

#include <stdlib.h>

int *mergesort(int *p,int *q, int n, int m)

{

    int i,index=0,j,t;

    static int arr3[20];

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

     {

        arr3[index]=*p;

        index++;

        p++;

     }

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

      {

         arr3[index]=*q;

         index++;

         q++;

      }

for(i = 1; i <= index; i++)                                       

for(j = 1; j <= index; j++)                                             

if(arr3[j-1] >= arr3[j])                                                 

{                

   t = arr3[j-1];                                                          

arr3[j-1] = arr3[j];                                           

arr3[j] = t;                                                       

}

           return arr3;

} int main()

{

  int arr1 [10], arr2 [10], *ptr;

      int i, n1, n2, m, index=0;

      scanf("%d", &n1);

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

      {

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

      }

        scanf ("%d", &n2 );

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

      {

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

         m = n1+n2;

      }

ptr=(int *) malloc( m * sizeof(int) );

ptr=mergesort(arr1, arr2, n1,n2);

for(i=1;i<=m;i++)

printf("%d\n", *(ptr+i));

return 0;    }