CTS Detailed Document For Campus Placement
CTS Detailed Document For Campus Placement
CTS Detailed Document For Campus Placement
Cognizant is the dream company for almost all engineers. Thus, it is a company that hundreds
of students apply to all across the world. It is important for you to be aware of the Cognizant
recruitment process before you attend the drive. Visit Cognizant’s website for more
information.
Academic Criteria
1) A candidate must have more than 60% marks in 10th and 12th (or diploma).
3) A maximum gap of 1 year is permissible after HSC(12th) and not after SSC(10th) or in
between semesters of graduation.
4) A candidate should not have any pending backlogs at the time of appearing for Cognizant
selection process.
Cognizant policies
1) If a candidate has attended an interview within the past 6 months from the date of new
application, then he/ she is ineligible to apply.
2) If a candidate has been rejected by Cognizant in an interview, then the candidate is ineligible
to apply again for a period of 6 months after the interview.
3) If for some reason Cognizant has terminated the candidate's application, then the candidate
is ineligible to apply.
4) If for any reason a candidate after applying in Cognizant, misses the opportunity to give the
interview then the candidate holds the right to apply again and can attend the selection
process.
Nidhi Gu
Anurag Singh
Cognizant Test pattern 2019 (on-campus)
1. On-campus Recruitment
Aptitude
Programming
HR
2. Off-campus Recruitment
Aptitude
Programming
Technical Round
HR
1. Logical Reasoning
Questions - 14
Time - 14 minutes
Difficulty - High
Cut-Off - 70%
2. Quantitative Aptitude
Questions - 16
Time - 16 minutes
Difficulty - Medium
Cut-Off - 70%
3. Verbal Ability
Questions - 25
Nidhi Gu
Anurag Singh
Time - 25 minutes
Difficulty - Medium
Cut-Off - 70%
4. Automata Fix
Questions - 7
Time - 20 minutes
Difficulty - High
Cut-Off - 70%
1. Aptitude Questions
Questions - 16
Time - 16 minutes
Difficulty - High
Cut-Off - 70%
2. Logical Questions
Questions - 14
Time - 14 minutes
Difficulty - Medium
Cut-Off - 70%
3. English Questions
Questions - 25
Time - 25 minutes
Difficulty - Medium
Cut-Off - 70%
4. Coding Questions
Questions - 2
Time - 60 minutes
Difficulty - Medium
Cut-Off - 70%
Nidhi Gu
Anurag Singh
Cognizant Syllabus (on-campus)
Section Topics
Nidhi Gu
Anurag Singh
Cognizant
Programming
Questions by No. of
Year Questions Languages allowed Cut off
2015 0 None Top 40%
2016 2 C, C++ Top 40%
2017 0 None Top 40%
2018 2 C, C++, Java, C# Top 30%
Cognizant programming test Questions are of moderate difficulty, in this section since a third
party hosts the round it is of moderate to high difficulty. So, practicing all the questions below
is highly recommended, if you do so then CTS Coding Questions and Answers can be a
cakewalk. This sections is also popularly known as Cognizant Automata Questions Round,
Cognizant Automata Round section in Programming Test of CTS generally has a time limit of 1
hour or 1 hour 30 mins depending on difficulty of the given Cognizant Online Programming
Questions to the student. We will suggest reading the CTS Programming Questions FAQ section
at the end of the page as well. We think about 60% of the students appearing for Cognizant
Coding Questions don’t clear this round of Cognizant Coding Test and are eliminated before the
interview round.
Nidhi Gu
Anurag Singh
AMCAT Programming (Automata) Questions – 1
int main()
{
int A[N][N] = { {1, 1, 1, 1},
{2, 2, 2, 2},
{3, 3, 3, 3},
{4, 4, 4, 4}};
if (areSame(A, B))
printf("Matrices are identical");
else
printf("Matrices are not identical");
return 0;
}
[/code]
Nidhi Gu
Anurag Singh
AMCAT Programming(Automata) Questions – 2
Input:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Output:
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
Input:
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
Output:
1 2 3 4 5 6 12 18 17 16 15 14 13 7 8 9 10 11
Code inC
[code language=”cpp”+
#include
#define R 3
#define C 6
voidspiralPrint(int m, int n, int a[R][C])
{
inti, k = 0, l = 0;
/* k – starting row index
m – ending row index
l – starting column index
n – ending column index
i – iterator
*/
Nidhi Gu
Anurag Singh
while (k < m && l < n)
{
/* Print the first row from the remaining rows */
for (i = l; i< n; ++i)
{
printf("%d ", a[k][i]);
}
k++;
/* Print the last column from the remaining columns */
for (i = k; i< m; ++i)
{
printf("%d ", a[i][n-1]);
}
n–;
/* Print the last row from the remaining rows */
if ( k < m)
{
for (i = n-1; i>= l; –i)
{
printf("%d ", a[m-1][i]);
}
m–;
}
/* Print the first column from the remaining columns */
if (l < n)
{
for (i = m-1; i>= k; –i)
{
printf("%d ", a[i][l]);
}
l++;
}
}
}
/* Driver program to test above functions */
intmain()
{
int a[R][C] = { {1, 2, 3, 4, 5, 6},
{7, 8, 9, 10, 11, 12},
{13, 14, 15, 16, 17, 18}
};
Nidhi Gu
Anurag Singh
spiralPrint(R, C, a);
return 0;
}
[/code]
1 2 3 4 5 6 12 18 17 16 15 14 13 7 8 9 10 11
Code in Java
*code language=”java”+
private static int[] spiral(int[][] matrix)
{ //Test if matrix is rectangular
intlen=matrix[0].length;
for(inti=1; i<matrix.length; i++)
{
if(matrix[i].length!=len)
{
System.out.println("Not rectangular"); return null;
}
}
int[] erg = new int[len*matrix.length];
int[] borders = new int[]{0,0,matrix.length-1, len-1};
int[] pointer = new int[]{0,0};
int state=0;
for(inti=0; i<erg.length; i++)
{
erg[i]=matrix[pointer[0]][pointer[1]];
switch (state)
{
case 0:
if(pointer[1] == borders[3])
{
state++;
pointer[0]++;
borders[0]++;
break;
}
pointer[1]++;
break;
case 1:
if(pointer[0] == borders[2])
Nidhi Gu
Anurag Singh
{ state++; pointer[1]–;
borders[3]–; break;
}
pointer[0]++;
break;
case 2: if(pointer[1] == borders[1])
{
state++; pointer[0]–;
borders[2]–; break; } p
ointer[1]–; break;
case 3:
if(pointer[0] == borders[0]){
state=0; pointer[1]++;
borders[1]++;
break;
}
pointer[0]–;
break;
}
}
return erg;
}
[/code]
Given an n-by-n matrix of 0’s and 1’s where all 1’s in each row come before all 0’s, find the
most efficient way to return the row with the maximum number of 0’s.
Please comment down the code in other languages as well below –
*code language=”cpp”+
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
#define COL 4
#define ROW 4
using namespace std;
int main()
{
intarr[ROW][COL]= {
{1,1,1,1},
{1,1,0,0},
Nidhi Gu
Anurag Singh
{1,0,0,0},
{1,1,0,0},
};
intrownum;
inti = 0, j = COL-1;
while(i<ROW && j>;0)
{
if(arr[i][j]==0)
{
j–;
rownum=i;}
else
i++;
}
printf("%d",rownum);
getch();
return 0;
}
[/code]
Input : limit = 20
Output : 3 4 5
8 6 10
5 12 13
15 8 17
12 16 20
A Simple Solution is to generate these triplets smaller than given limit using three nested loop.
For every triplet, check if Pythagorean condition is true, if true, then print the triplet. Time
complexity of this solution is O(limit3) where ‘limit’ is given limit.
An Efficient Solution can print all triplets in O(k) time where k is number of triplets printed. The
idea is to use square sum relation of Pythagorean triplet, i.e., addition of squares of a and b is
equal to square of c, we can write these number in terms of m and n such that,
Nidhi Gu
Anurag Singh
a = m2 - n 2
b=2*m*n
c = m2 + n 2
because,
a2 = m4 + n4 – 2 * m2 * n2
b2 = 4 * m2 * n2
c2 = m4 + n4 + 2* m2 * n2
We can see that a2 + b2 = c2, so instead of iterating for a, b and c we can iterate for m and n and
can generate these triplets.
Below is C implementation of above idea.
*code language=”cpp”+
// A C program to generate pythagorean triplets
// smaller than a given limit
#include <stdio.h>
#include <math.h>
Nidhi Gu
Anurag Singh
if (c > limit)
break;
// Driver program
int main()
{
int limit = 20;
pythagoreanTriplets(limit);
return 0;
}
[/code]
345
8 6 10
5 12 13
15 8 17
12 16 20
Time complexity of this approach is O(k) where k is number of triplets printed for a given limit
(We iterate for m and n only and every iteration prints a triplet)
#include
int main()
{
int n1, n2,i,gcd;
Nidhi Gu
Anurag Singh
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;
}
return0;
}
#include
int main()
{
int n1, n2;
while(n1!=n2)
{
if(n1 > n2)
Nidhi Gu
Anurag Singh
n1 -= n2;
else
n2 -= n1;
}
printf("GCD = %d",n1);
return0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
# define FALSE 0
intcheck_vowel(char);
main() {
char string[100], * temp, * pointer, ch, * start;
printf(“Enter a string\n”);
gets(string);
temp = string;
pointer = (char * ) malloc(100);
if (pointer == NULL) {
printf(“Unable to allocate memory.\n”);
exit(EXIT_FAILURE);
}
start = pointer;
while ( * temp) {
ch = * temp;
if (!check_vowel(ch)) { * pointer = ch;
pointer++;
Nidhi Gu
Anurag Singh
}
temp++;
} * pointer = ‘\0’;
pointer = start;
strcpy(string, pointer); /* If you wish to convert original string */
free(pointer);
printf(“String after removing vowel is \”%s\”\n”, string);
return 0;
}
intcheck_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;
Examples:
#include <bits/stdc++.h>
using namespace std;
// Driver code
int main()
{
int a[] = { 10, 5, 15 };
int b[] = { 20, 3, 2, 12 };
int n = sizeof(a) / sizeof(a[0]);
int m = sizeof(b) / sizeof(b[0]);
return 0;
}
} Top of Form
How to Find LCM of three numbers
Please write your version or code in other Languages below in comments.
C
C++
Java
Nidhi Gu
Anurag Singh
If you can write a program to find LCM of two numbers. Then you can very easily write a
program to find LCM of three numbers also , cause
lcm(a,b,c)=lcm(a,lcm(b,c))lcm(a,b,c)=lcm(a,lcm(b,c)).
int lcm(int,int);
int main(){
inta,b,c,l,k;
printf("Enter any three positive integers ");
scanf("%d%d%d",&a,&b,&c);
if(a<b)
l = lcm(a,b);
else
l = lcm(b,a);
if(l>c)
k= lcm(l,c);
else
k= lcm(c,l);
return 0;
int temp = a;
while(1){
Nidhi Gu
Anurag Singh
break;
temp++;
return temp;
}
[/code]
Code in C++
[code language=”cpp”+
#include<iostream>
using namespace std;
LCM = lcm(a,b,c);
HCF = hcf(a,b,c);
cout<<"LCM of "<<a<<","<<b<<","<<c<<" is = "<<LCM<<endl;
cout<<"HCF of "<<a<<","<<b<<","<<c<<" is = "<<HCF<<endl;
return 0;
}
int lcm(intx,int y, int z)
{
longmax,lcom, count, flag=0;
if(x>=y&&x>=z)
max=x;
else if(y>=x&&y>=z)
max=y;
Nidhi Gu
Anurag Singh
else if(z>=x&&z>=y)
max=z;
for(count=1;flag==0;count++)
{
lcom=max*count;
if(lcom%x==0 &&lcom%y==0 &&lcom%z==0)
{
flag=1;
}
}
returnlcom;
}
*code language=”java”+
public class LCM {
Nidhi Gu
Anurag Singh
* lcm (n1,n2,… 0)=0.For negative number we convert into
* positive and calculate lcm.
*/
if (numbers[i] == 0) {
return 0;
} else if (numbers[i] < 0) {
numbers[i] = numbers[i] * (-1);
}
if (numbers[i] == 1) {
cnt++;
}
/**
* divide numbers by devisor if complete division i.e. without
* remainder then replace number with quotient; used for find
* next factor
*/
if (numbers[i] % divisor == 0) {
divisible = true;
numbers[i] = numbers[i] / divisor;
}
}
/**
* If divisor able to completely divide any number from array
* multiply with lcm and store into lcm and continue to same divisor
* for next factor finding. else increment divisor
*/
if (divisible) {
lcm = lcm * divisor;
} else {
divisor++;
}
/**
* Check if all numbers is 1 indicate we found all factors and
* terminate while loop.
*/
if (cnt == numbers.length) {
return lcm;
}
}
}
Nidhi Gu
Anurag Singh
return 0;
}else if(num1<0){
num1=num1*(-1);
}else if(num2<0){
num2=num2*(-1);
}
int m = num1;
int n = num2;
while (num1 != num2) {
if (num1 < num2) {
num1 = num1 + m;
} else {
num2 = num2 + n;
}
}
return num1;
}
}
}
[/code]
Output:
*** Least Common Multiple ***
LCM(Least Common Multiple) of N numbers using Table method
32760
LCM of two numbers using repetative addition
72
Nidhi Gu
Anurag Singh