Cognizant Programmer Trainee Interview Questions

Cognizant Programmer Trainee

Cognizant Programmer Trainee is an entry-level role in Cognizant. In this page, you will find Cognizant Programmer Trainee Interview Questions and Answers.

Page Highlights:

What is Cognizant Programmer Trainee?

Programmer Trainee in Cognizant is a role offered to freshers, as an entry level job. Students from BCA and B.Sc. are eligible for this profile. The job profile of a Programmer Trainee in Cognizant revolves around learning and working with technologies and software. Candidates with good programming skills and fair knowledge of MySql, .Net etc. are preferred for this role.

Cognizant Programmer Trainee Eligibility Criteria

  • B.Sc. and BCA students are eligible
  • Minimum of 60% in X, XII and graduation
  • No standing arrears.

What is Cognizant Programmer Trainee Salary?

A fresher Programmer Trainee in Cognizant makes around Rs. 2.5 lakhs per annum. This amount will increase as an employee gains experience and works on different projects in Cognizant.

Cognizant Programmer Trainee Interview Questions and Answers

For Cognizant Programmer Trainee Profile, two interviews are conducted. 

  • Cognizant Programmer Trainee Technical Interview
  • Cognizant Programmer Trainee HR Interview

Cognizant Programmer Trainee Interview Topics

For Cognizant Programmer Trainee role, the interviewer will ask questions on topics including:-

  • Resume based questions
  • Project based questions
  • Internship/Certification questions
  • Technical questions on programming languages like C, Java, Python
  • Coding questions
  • DBMS and SQL questions

Cognizant Programmer Trainee Technical Interview Questions

1.What is the difference between local variable and global variable in C?

Answer:

 

Basis for comparisonLocal variableGlobal variable
DeclarationA variable that is declared inside a function or block is known as a local variable.A variable that is declared outside function or block is known as a global variable.
ScopeThe scope of a variable is within a function in which they are declared.The scope of a variable is throughout the program.
AccessVariables can be accessed only by those statements inside a function in which they are declared.Any statement in the entire program can access variables.
LifeLife of a variable is created when the function block is entered and destroyed on its exit.Life of a variable exists until the program is executing.
StorageVariables are stored in a stack unless specified.The compiler decides the storage location of a variable.

2.What do you mean by an IDE?

Answer:

An IDE or Integrated Development Environment which helps programmer design and build applications.

3.What is recursion in C?

Answer:

In some cases, a function can call itself, this process is called recursion and this function is called a recursive function. There are two phases of recursion:-

  • winding phase
  • unwinding phase

4.What is a pointer in C?

Answer:

A pointer is a variable that refers to the address of a value. Whenever a variable is declared inside a program then the system allocates some memory to a variable. The memory contains some address number. The variables that hold this address number is known as pointer variable.

5.What is package in Java?

Answer:

Packages in Java are collection of related classes and interfaces which are bundled together. Packages help in code reusability.

6.What are the main concepts of OOPs in Java?

Answer:

  • Inheritance:- inheritance is the process  by which one class (child class) can acquire the properties of another class (parent class).
  • Encapsulation:- Encapsulation in Java wraps up the data and code together in a single unit.
  • Abstraction:- Abstraction hides the implementation details from users.
  • Polymorphism:- Polymorphism is the ability of a variable, function or object to take multiple forms.

7.What is aggregation?

Answer:

Aggregation is the relationship between two classes where the aggregate class contains a reference to the class it owns. 

8.What is exception handling?

Answer:

Exception handling in OOPs is used to manage errors. Exception handler allows errors to be thrown and caught and implements a centralized mechanism to resolve them.

9.What is the purpose of normalization in DBMS?

Answer:

Normalization is the process of analyzing relational schemas which are based on their respective functional dependencies and the primary keys in order to fulfill certain properties, including:

  • minimize data redundancy
  • minimize Insert, Delete and Update anomalies

10.What is data abstraction in DBMS?

Answer:

Data abstraction in DBMS is a process of hiding irrelevant details from users.

11. Define Atomicity and Aggregation.

Answer:

  • Atomicity: It assures a users that incomplete transactions will be taken care of. Incomplete transactions are left undone in DBMS.
  • Aggregation: The collected entities and their relationship are aggregated in this model. It is used in expressing relationships within relationships.

12. What are the types of joins? Explain.

Answer:

  • Inner Join: Returns rows when there is at least one match of rows between tables.
  • Right Join: Returns rows which are common between the tables and rows of the right hand side table.
  • Left Join: Returns rows which are common between the tables and rows of the left-hand side table.
  • Full Join: Returns rows when there are matching rows in any one of the tables

13.What is a query?

Answer:

Query is a request for data. A database query is written in order to get information from the database.

14.What do you understand by SDLC models?

Answer:

SDLC models define all the phases of software development. The different SDLC models include:-

  • waterfall model
  • iteratice waterfall model
  • agile model
  • spiral model
  • prototype model

15.What are the various phases of software development lifecycle?

Answer:

The phases of SDLC include:-

  1. Research and Resources Gathering
  2. System Analysis
  3. Design
  4. Coding
  5. Testing
  6. Implementation

Find Most Asked Technical Interview Questions here : 

Cognizant Programmer Trainee Coding Questions

Question 1: 

Write a program to check if a number is palindrome or not.

#include<stdio.h>
// Palindrome is a number that is same if read forward/backward
// Ex : 12321
int main ()
{
int num, reverse = 0, rem, temp;

printf("Enter a number: ");
scanf("%d",&num);

temp = num;

//loop to find reverse number
while(temp != 0)
{
rem = temp % 10;
reverse = reverse * 10 + rem;
temp /= 10;
};

// palindrome if num and reverse are equal
if (num == reverse)
printf("%d is Palindrome", num);
else
printf("%d is Not Palindrome", num);

}
import java.lang.*;

class LearnCoding {
public static void main(String[] args) {
String str = "Civic";
String reverse = "";

// building reverse string char by char from str
for(int i = str.length() - 1; i >= 0; i--){
reverse = reverse + str.charAt(i);
}

// checking if both are same or not
if(checkPalindrome(str, reverse))
System.out.println(str + " is Palindrome");
else
System.out.println(str + " is not Palindrome");

}

private static boolean checkPalindrome(String str, String reverse) {
// 1. convert both string to lowercase
// 2. Check if both strings are equal using .equals function
return str.toLowerCase().equals(reverse.toLowerCase());
}
}
num = int(input("Enter the Number:"))
temp = num
reverse = 0
while num > 0:
remainder = num % 10
reverse = (reverse * 10) + remainder
num = num // 10

if temp == reverse:
print("Given number {} is Palindrome".format(temp))
else:
print("Given number {} is not Palindrome".format(temp))
#include  
using namespace std;

//main program
int main ()
{
    //variables initialization
    int num, reverse = 0, rem, temp;
 
    cout <<"Enter a number: "; 
    cin >> num;
 
    temp = num;
    //loop to find reverse number
    while(temp != 0)
    {
        rem = temp % 10;
        reverse = reverse * 10 + rem;
        temp /= 10;
    };
    
    // palindrome if num and reverse are equal
    if (num == reverse)
        cout << num << " is Palindrome";
    else
        cout << num << " is not a Palindrome";

}

Question 2: 

Write a program to check for leap year.

#include 
int main ()
{
int year;
scanf("%d",&year);

if(year % 400 == 0)
printf("%d is a Leap Year",year);

else if(year % 4 == 0 && year % 100 != 0)
printf("%d is a Leap Year",year);

else
printf("%d is not a Leap Year",year);

return 0;
}
public class Main
{
public static void main (String[]args)
{

int year = 2020;

if (year % 400 == 0)
System.out.println (year + " is a Leap Year");

else if (year % 4 == 0 && year % 100 != 0)
System.out.println (year + " is a Leap Year");

else
System.out.println (year + " is not a Leap Year");

}
}
year = int(input("Enter Year:"))
if (year%400 == 0) or (year%4==0 and year%100!=0):
print("Leap Year")
else:
print("Not a Leap Year")
#include<bits/stdc++.h>
using namespace std;

int main()
{
int year;

cout << "Enter Year:" << endl; cin >> year;

if(year % 400 == 0)
cout << year << " is a Leap Year";

else if(year % 4 == 0 && year % 100 != 0)
cout << year << " is a Leap Year";

else
cout << year << " is not a Leap Year";

return 0;
}

Question 3: 

Find the prime numbers between 1 to 100.

#include

int checkPrime(int num)
{
// 0, 1 and negative numbers are not prime
if(num < 2){
return 0;
}
else{
// no need to run loop till num-1 as for any number x the numbers in
// the range(num/2 + 1, num) won't be divisible anyways.
// Example 36 wont be divisible by anything b/w 19-35
int x = num/2;
for(int i = 2; i < x; i++)
{
if(num % i == 0)
{
return 0;
}
}
}
// the number would be prime if we reach here
return 1;
}

int main()
{
int a = 1, b = 100;

for(int i=a; i <= b; i++){
if(checkPrime(i))
printf("%d ",i);
}

return 0;
}
//Java Program to find prime no 1 to 100
public class Main
{
     public static void main(String[] args)
     {
         int i,j,count=0;
         //print prime no between 1 to 100
         System.out.println("prime number between 1 to 100\n");

         //loop for printing prime no between 1 to 100
         for(i=2;i<=100;i++)
         {
            for(j=1;j<=i;j++)
            {
              if(i%j==0)
                count++;
            }
            if(count==2)
              System.out.print(" "+i);
            count=0;
          }
}
#To find the prime numbers between 1 to 100 

li=[] #list of prime numbers will be stored here 

for i in range(2,101):

    f=0

    for j in range(2,i+1):

        if(i!=j and i%j==0): #if any n

            f=1

            break 

    if(f==0):

        li.append(i)

print('Prime numbers between 1 to 100:')

print(*li,sep=' ')
//Cpp Code to find prime number between 1 to 100
#include
using namespace std;
///Main Function
int main()
{
int i,j,count=0;

//Print prime number between 1 to 100
cout<<"print prime number between 1 to 100\n";

//For loop for printing values between 1 to 100
for(i=2;i<=100;i++)
{
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;

}
if(count==2)
cout<<" "<<i;
count=0;
}
return 0;
}

Question 4: 

Write a code to reverse an array.

#include

void printReverse(int arr[], int len){

for(int i = len - 1; i >= 0; i--)
printf("%d ", arr[i]);
}

int main()
{
int arr[] = {10, 20, 30, 40, 50, 60};

int len = sizeof(arr)/sizeof(arr[0]);

printf("Array in Reverse:\n");
printReverse(arr, len);

return 0;
}
def reverseList(A, start, end):
while start < end:
A[start], A[end] = A[end], A[start]
start += 1
end -= 1
# Driver function to test above function
A = [10, 20, 30, 40, 50]
reverseList(A, 0, 4)
print(A)
#include<bits/stdc++.h>
using namespace std;

int main(){

int arr[] = {10, 20, 30, 40, 50};
int n = sizeof(arr)/sizeof(arr[0]);

for(int i=n-1; i>=0; i--)
cout<<arr[i]<<" ";
}

Question 5: 

Write a program to check if two strings are anagram or not

#include

int main()
{
//Initializing variables.
char str[100];
int i;
int freq[256] = {0};

//Accepting inputs.
printf("Enter the string: ");
gets(str);

//Calculating frequency of each character.
for(i = 0; str[i] != '\0'; i++)
{
freq[str[i]]++;
}

printf("The non repeating characters are: ");
for(i = 0; i < 256; i++)
{
if(freq[i] == 1)//Finding uniques charcters and printing them.
{
printf(" %c ", i);
}
}
return 0;
}
import java.util.Arrays;
import java.util.Scanner;
public class CheckIfTwoStringsAreAnagramAreNot {
static boolean isAnagram(String str1 , String str2) {
String s1 = str1.replaceAll("[\\s]", "");
String s2 = str2.replaceAll("[\\s]", "");
boolean status=true;

if(s1.length()!=s2.length())
status = false;
else {
char[] a1 = s1.toLowerCase().toCharArray();
char[] a2 = s2.toLowerCase().toCharArray();
Arrays.sort(a1);
Arrays.sort(a2);
status = Arrays.equals(a1, a2);
}
return status;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter two String :");
String s1 = sc.next();
String s2 = sc.next();
boolean status = isAnagram(s1,s2);
if(status)
System.out.println(s1+" and "+s2+" are Anagram");
else
System.out.println(s1+" and "+s2+" are not Anagram");
}
}
#take user input
String1 = input('Enter the 1st string :')
String2 = input('Enter the 2nd string :')
#check if length matches
if len(String1) != len(String2):
#if False
print('Strings are not anagram')
else:
#sorted function sort string by characters
String1 = sorted(String1)
String2 = sorted(String2)
#check if now strings matches
if String1 == String2:
#if True
print('Strings are anagram')
else:
print('Strings are not anagram')
#include 
using namespace std;
int main()
{
//Initializing variables.
char str1[100],str2[100];
int first[26]={0}, second[26]={0}, c=0, flag=0;

//Accepting inputs.
cout<<"Enter First String: ";
gets(str1);
cout<<"Enter Second String: ";
gets(str2);

//Calculating frequencies of characters in first string.
while(str1[c] != '\0')
{
first[str1[c]-'a']++;
c++;
}

c=0;
//Calculating frequencies of characters in second string.
while(str2[c] != '\0')
{
second[str2[c]-'a']++;
c++;
}
//Checking if frequencies of both the strings are same or not.
for(c=0;c<26;c++)
{
if(first[c] != second[c])
flag=1;
}
//Priting result.
if(flag == 0)
{
cout<<"Strings are anagram.";
}
else
{
cout<<"Strings are not anagram.";
}
return 0;

}

Also Check:

Cognizant Programmer Trainee Interview Preparation

Interview Preparation

Find the most asked technical questions with answers, most asked HR questions and how to solve them. Also includes most asked coding questions and top 100 Interview Puzzles

Cognizant Programmer Trainee Interview Experience

Interview Experience

Read Interview Experiences of candidates selected and placed in various service based and product based companies include Microsoft, Cognizant, Infosys, PayPal and more

FAQs on Cognizant Programmer Trainee

Question: What is the salary of programmer trainee in Cognizant?

Answer:-

The salary of Cognizant Programmer Trainee is  Rupees 2.5 lakhs per annum, for freshers. For experienced candidates the salary can be up to 4 lakhs per annum.

Question: What is programmer trainee?

Answer:-

As a programmer trainee in Cognizant you will be working on projects, where you are led by a supervisor. These projects are assigned based on the technologies you are taught in your training period.