Cognizant Technical Round (3 Oct 2024)
Cognizant Technical Round (3 Oct 2024)
Q1) Write an SQL query to display: The loan id, load amount and loan disbursed date (loan date) of
all the loans taken from 1 June, 2023 and whose loan amount is between 50000 to 100000. Your
output should have 3 columns as given below:
FROM loans
Q2)
SELECT ei.EMPNAME, si.TRAVELING_ALLOWANCE
FROM employee_info ei
You are developing a weather analysis tool for a local meteorological department. Your tool is
designed to analyze temperature readings from various days to understand the variation in
temperatures over a specific period.
The department wants to quantify how much temperatures differ from one day to another. Your
task is to find and return an integer value representing the sum of the squares of the differences in
temperature readings for every unique pair of days in the given temperature array.
Input Specification:
Example 1:
input1: {1, 2, 3}
input2 : 3
Output: 6 Explanation: Here, the temperature on the specific day is {1, 2, 3} . The square of
differences in temperatures readings for every unique pair of days can be calculated as below:
• (1 - 2) ^ 2 = 1
• (1 - 3) ^ 2 = 4
• (2 - 3) ^ 2 = 1
Example 2:
input1: {4, 5}
input2: 2
Output: 1
Explanation: Here, the temperature on the specific day is {4, 5} The square of mragr differences in
temperatures readings for every unique pair of days can be calculated as below:
Code:
int sum = 0;
}
return sum;
// Test Example 1
int input2 = 3;
// Test Example 2
int input2_2 = 2;
Q4)
A poet has asked you for assistance in writing poems. He has given you a string S and a dictionary D
and he asks you to find, from the dictionary, a word which rhymes best with S. Words are said to
rhyme when the last syllables of the words are the same, like "cave" and "gave", or "typical" and
"critical." The words will be deemed to rhyme best if the last few characters of the words match the
most. Your task is to find and return a string value denoting the word which rhymes best with S,
from the dictionary D. If no such word is found, return the string "No Word".
Note: If all the characters match, it is the same word and not a rhyming word.
• All the given words are in lowercase. • If multiple rhyming words are found, then choose the word
with the least index.
Input Specification:
Output Specification: Return a string value denoting the word which rhymes best with S from the
dictionary D. If no such word is found, return the string "No Word".
Example 1:
input1: thunder
input2: (puzzle, thunder, powder, blender, under)
input3: 5
Output: under
Explanation: Here, the given word S is "thunder." We can find the rhyming word/s trom the
dictionary in the followingway: • The first word "puzzle" does not rhyme at all and has no common
characters with the word "thunder" at the end. • The second word "thunder" is exactly the same
word as the given word, so it will not be considered as a rhyming word. • The third word is "powder"
and has the 3 letters "der" in common at the end and is the least rhyming among the list. • The
fourth word is "blender" and has the 4 letters "nder" in common at the end and is the second most
rhyming among the list. • The last word is "under" and it is the most rhyming word as it has the 5
letters "under" in common with the word at the end.
Since "under" is the most rhyming word among those in the given dictionary, under is returned as
the output.
Code:
int maxLength = 0;
if (word.equals(S)) {
continue;
int commonLength = 0;
commonLength++;
} else {
break;
}
// Update the best rhyme if this word has a longer common suffix
maxLength = commonLength;
bestRhyme = word;
int input3 = 5;
Q5)
You are creating a Password Reset Page for a new Website. The goal is to set up the correct style
and ids for Reset forms. However, the project is not yet complete, and you need to finish it.
Objectives:
• Create a button with type "submit", id "resetButton" and inner text "Reset Password".
• If the passwords entered in the two input fields match, display the message "Password reset
successful", else display "Passwords do not match". The message should get displayed in the para
tag with the id "message".
Constraints: • Do not change the id or class attributes of any elements, as they are used by the
JavaScript code. • Ensure that the styling is applied correctly according to the provided CSS.
Here’s a simple example of how you can achieve the objectives for the password reset page using
HTML, CSS, and JavaScript:
HTML:
html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Password Reset</title>
</head>
<body>
<div class="reset-container">
<h2>Reset Password</h2>
<form id="resetForm">
</form>
<p id="message"></p>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css):
#resetButton {
border: none;
border-radius: 5px;
cursor: pointer;
.reset-container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
border-radius: 10px;
background-color: #f9f9f9;
#message {
color: red;
font-size: 14px;
JavaScript (script.js):
} else {
});
Explanation:
● HTML: Creates a form with two password input fields and a button. A paragraph (<p>) with
the id="message" is used to display feedback to the user.
● CSS: Applies styling to the reset button and ensures the button's text color is white.
● JavaScript: Checks if the two passwords entered by the user match and updates the message
accordingly.