0% found this document useful (0 votes)
8 views7 pages

coding part-4

tcs nqt coding questions

Uploaded by

ashutomar7014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

coding part-4

tcs nqt coding questions

Uploaded by

ashutomar7014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

TCS CODING

QUESTIONS 16-20
QUESTION - 16

Problem Statement: A doctor has a clinic where he serves his patients. The doctor’s consultation fees are
different for different groups of patients depending on their age. If the patient’s age is below 17, fees is 200
INR. If the patient’s age is between17 and 40, fees is 400 INR. If patient’s age is above 40, fees is 300 INR.
Write a code to calculate earnings in a day for which one array/List of values representing age of patients
visited on that day is passed as input.
Note:
• Age should not be zero or less than zero or above 120
• Doctor consults a maximum of 20 patients a day
• Enter age value (press Enter without a value to stop):
QUESTION - 16

Example 1: Input

20

30

40

50

14

Output : Total Income 2000 INR

Note: Input and Output Format should be same as given in the above example. For any wrong input display INVALID INPUT

Output Format : Total Income 2100 INR


QUESTION - 17

Prime Numbers with a Twist


Ques. Write a code to check whether no is prime or not. Condition use function check() to
find whether entered no is positive or negative ,if negative then enter the no, And if yes pas
no as a parameter to prime() and check whether no is prime or not?
• Whether the number is positive or not, if it is negative then print the message
“please enter the positive number”
• It is positive then call the function prime and check whether the take positive
number is prime or not.
QUESTION - 18

Number Series with a Twist – 1


Find the 15th term of the series?
0,0,7,6,14,12,21,18, 28
Explanation :
In this series the odd term is increment of 7 {0, 7, 14, 21, 28, 35 – – – – – – }
And even term is a increment of 6 {0, 6, 12, 18, 24, 30 – – – – – – }
QUESTION - 19

Number Series with a Twist 2


Link to this Question
Consider the following series: 1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243, 64, 729, 128, 2187 … This series is a
mixture of 2 series – all the odd terms in this series form a geometric series and all the even terms form
yet another geometric series. Write a program to find the Nth term in the series.
The value N in a positive integer that should be read from STDIN. The Nth term that is calculated by the
program should be written to STDOUT. Other than value of n th term,no other character / string or
message should be written to STDOUT. For example , if N=16, the 16th term in the series is 2187, so only
value 2187 should be printed to STDOUT. You can assume that N will not exceed 30
QUESTION - 20

Number Series with a Twist 3


Link to this Question –
Consider the below series : 0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8
This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is
derived from the previous term using the formula (x/2) Write a program to find the nth term in this series.
The value n in a positive integer that should be read from STDIN the nth term that is calculated by the program should be
written to STDOUT. Other than the value of the nth term no other characters /strings or message should be written to
STDOUT.
For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th
term is (8/2)=4. Only the value 4 should be printed to STDOUT. You can assume that the n will not exceed 20,000.

You might also like