Professional Documents
Culture Documents
TCS NQT Problem Statements
TCS NQT Problem Statements
TCS NQT Problem Statements
Problem Statement 1
An automobile company manufactures both a two wheeler (TW) and a four wheeler (FW). A
company manager wants to make the production of both types of vehicle according to the
given data below:
The task is to find how many two-wheelers as well as four-wheelers need to manufacture as
per the given data.
Example :
Input :
200 -> Value of V
540 -> Value of W
Output :
TW =130 FW=70
Explanation:
130+70 = 200 vehicles
(70*4)+(130*2)= 540 wheels
Constraints :
2<=W
W%2=0
V<W
Written program code should generate two outputs, each separated by a single space
character(see the example)
Additional messages in the output will result in the failure of test case
Solution in C:
#include <stdio.h>
int main() {
int v, w, tw, fw;
// Accepting input from the user
scanf("%d", &v);
scanf("%d", &w);
// Checking constraints
if (w < 2 || w % 2 != 0 || v >= w) {
printf("INVALID INPUT");
} else {
// Calculating the number of two-wheelers and four-wheelers
fw = w / 4;
tw = v - fw;
// Printing the output
printf("TW=%d FW=%d", tw, fw);
}
return 0;
}
Solution in python:
Control Statements:
Creatnx now wants to decorate his house by flower pots. He plans to buy exactly N
ones. He can only buy them from Triracle's shop. There are only two kind of
flower pots available in that shop. The shop is very strange. If you buy X flower
pots of kind 1 then you must pay A x X^2 and B x Y^2? if you buy Y flower pots
of kind 2. Please help Creatnx buys exactly N flower pots that minimizes money he
pays.
Input Format
The first line contains a integer T denoting the number of test cases.
Constraints
Output Format
For each test case, print a single line containing the answer.
Sample Input;
512
10 2 4
Sample Output:
17
134
Python Code:
C Code:
#include <stdio.h>
int main() {
int T; // Number of test cases
scanf("%d", &T);
return 0;
}
Problem statement
Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to
withdraw.
Nonnegative number 0<= Y <= 2000 with two digits of precision - Pooja's initial
account balance.
Output Format
Output the account balance after the attempted transaction, given as a number with
two digits of precision. If there is not enough money in the account to complete the
transaction, output the current bank balance.
Sample Input:
30 120.00
Sample Output:
89.50
Python Code:
def main():
X = int(input("Enter the amount you wish to withdraw: "))
Y = float(input("Enter your initial account balance: "))
bank_charge = 0.50
if __name__ == "__main__":
main()
C Code:
#include <stdio.h>
int main() {
int X;
float Y, bankCharge = 0.50;
return 0;
}