TCS NQT Coding Questions 2021 with sollution

Spread the love

TCS  conducts NQT  in every 3months ,so in every 3months we comes with the sollution for every questions and here it is. In before tcs conducts this test in free of cost but now tcs charge for the NQT test and also offers palcements in other companies. if you score more than 1300 in NQT then  you get a call for tcs interview else if you secure 1000 or less 1200 then you got a call from other companies. that’s all

TCS NQT Coding Question 2021 – Day 1 – Slot 1

QUESTION 1:

There is a JAR full of candies for sale at a mall counter. JAR has the capacity N, that is JAR can contain maximum N candies when JAR is full. At any point of time. JAR can have M number of Candies where M<=N. Candies are served to the customers. JAR is never remain empty as when last k candies are left. JAR if refilled with new candies in such a way that JAR get full.
Write a code to implement above scenario. Display JAR at counter with available number of candies. Input should be the number of candies one customer can order at point of time. Update the JAR after each purchase and display JAR at Counter.

Output should give number of Candies sold and updated number of Candies in JAR.

If Input is more than candies in JAR, return: “INVALID INPUT”

Given, 

N=10, where N is NUMBER OF CANDIES AVAILABLE

K =< 5, where k is number of minimum candies that must be inside JAR ever.

Example 1:(N = 10, k =< 5)

  • Input Value
    • 3
  • Output Value
    • NUMBER OF CANDIES SOLD : 3
    • NUMBER OF CANDIES AVAILABLE : 7

Example : (N=10, k<=5)

  • Input Value
    • 0
  • Output Value
    • INVALID INPUT
    • NUMBER OF CANDIES LEFT : 10

 

#include
int main()
{
int n=10, k=5;
int num;
scanf(“%d”,&num);
if(num>=1 && num<=5)
{
printf("NUMBER OF CANDIES SOLD : %dn",num);
printf("NUMBER OF CANDIES LEFT : %d",n-num);
}
else
{
printf("INVALID INPUTn");
printf("NUMBER OF CANDIES LEFT : %d",n);
}
return 0;
}

#include <iostream.h>
using namespace std;
int main()
{
	int n=10, k=5;
	int num;
	cin>>num;
	if(num>=1 && num<=5)
	{
    	cout<< "NUMBER OF CANDIES SOLD : "<<num<<"n";
    	cout<<"NUMBER OF CANDIES LEFT : "<<n-num;
	}
	else
	{
    	cout<<"INVALID INPUTn";
    	cout<<"NUMBER OF CANDIES LEFT : "<<n;
	}
	return 0;
}
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
   	 int n = 10, k = 5;
   	 int num;
   	 Scanner sc = new Scanner(System.in);
   	 num = sc.nextInt();
   	 if(num >= 1 && num <= 5) {
   		 System.out.println("NUMBER OF CANDIES SOLD : " + num);
   		 System.out.print("NUMBER OF CANDIES LEFT : " + (n - num));
   	 } else {
   		 System.out.println("INVALID INPUT");
   		 System.out.print("NUMBER OF CANDIES LEFT : " + n);
   	 }
    }
}
total_candies = 10
no_of_candies = int(input())
if no_of_candies in range(1, 6):
	print('No. of Candies Sold:',no_of_candies)
	print('No. of Candies Left:',total_candies-no_of_candies)
else:
	print("Invalid Input")
	print('No. of Candies Left:',total_candies)

TCS NQT coding questions 2021

previous slot solution click on to it

 

 

QUESTION NO 2:

Selection of MPCS exams include a fitness test which is conducted on ground. There will be a batch of 3 trainees, appearing for running test in track for 3 rounds. You need to record their oxygen level after every round. After trainee are finished with all rounds, calculate for each trainee his average oxygen level over the 3 rounds and select one with highest oxygen level as the most fit trainee. If more than one trainee attains the same highest average level, they all need to be selected.

Display the most fit trainee (or trainees) and the highest average oxygen level.

Note:

  • The oxygen value entered should not be accepted if it is not in the range between 1 and 100.
  • If the calculated maximum average oxygen value of trainees is below 70 then declare the trainees as unfit with meaningful message as “All trainees are unfit.
  • Average Oxygen Values should be rounded.

Example 1:

  • INPUT VALUES

95

92

95

92

90

92

90

92

90

  • OUTPUT VALUES
    • Trainee Number : 1
    • Trainee Number : 3

Note:

Input should be 9 integer values representing oxygen levels entered in order as

Round 1

  • Oxygen value of trainee 1
  • Oxygen value of trainee 2
  • Oxygen value of trainee 3

Round 2

  • Oxygen value of trainee 1
  • Oxygen value of trainee 2
  • Oxygen value of trainee 3

Round 3

  • Oxygen value of trainee 1
  • Oxygen value of trainee 2
  • Oxygen value of trainee 3
#include <stdio.h>   
int main()  
{
	int trainee[3][3];
	int average[3] = {0};
	int i, j, max=0;
	for(i=0; i<3; i++)
	{
    		for(j=0; j<3; j++)
    		{
        		scanf("%d",&trainee[i][j]);
        		if(trainee[i][j]<1 || trainee[i][j]>100)
        		{
            		trainee[i][j] = 0;
        		}
    		}
	}
	for(i=0; i<3; i++)
	{
    		for(j=0; j<3; j++)
    		{
        			average[i] = average[i] + trainee[j][i];
    		}
    		average[i] = average[i] / 3;
	}
	for(i=0; i<3; i++) { if(average[i]>max)
    		{
        			max = average[i];
    		}
	}
	for(i=0; i<3; i++)
	{
    		if(average[i]==max)
    		{
        			printf("Trainee Number : %dn",i+1);
    		}
    		if(average[i]<70)
    		{
        			printf("Trainee is Unfit");
    		}
	}
	return 0;
}
#include<iostream.h> 
using namespace std;
int main()  
{
	int trainee[3][3];
	int average[3] = {0};
	int i, j, max=0;
	for(i=0; i<3; i++)
	{
        	for(j=0; j<3; j++) { cin>>trainee[i][j];
                	if(trainee[i][j]<1 || trainee[i][j]>100)
                	{
                    	trainee[i][j] = 0;
            	}
        	}
	}
	for(i=0; i<3; i++)
	{
        	for(j=0; j<3; j++)
        	{
                	average[i] = average[i] + trainee[j][i];
        	}
        	average[i] = average[i] / 3;
	}
	for(i=0; i<3; i++) { if(average[i]>max)
        	{
                	max = average[i];
        	}
	}
	for(i=0; i<3; i++)
	{
        	if(average[i]==max)
        	{
                	cout<<"Trainee Number : "<<i+1<<"n";
        	}
        	if(average[i]<70)
        	{
                	cout<<"Trainee is Unfit";
        	}
	}
	return 0;
}
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
   	 int[][] trainee = new int[3][3];
   	 int[] average = new int[3];
   	 int max = 0;
   	 Scanner sc = new Scanner(System.in);
   	 for(int i = 0; i < 3; i++) {
   		 for(int j = 0; j < 3; j++) {
   			 trainee[i][j] = sc.nextInt();
   			 if(trainee[i][j] < 1 || trainee[i][j] > 100) {
   				 trainee[i][j] = 0;
   			 }
   		 }
   	 }
   	 for(int i = 0; i < 3; i++) {
   		 for(int j = 0; j < 3; j++) {
   			 average[i] = average[i] + trainee[j][i];
   		 }
   		 average[i] = average[i] / 3;
   	 }
   	 for(int i = 0; i < 3; i++) {
   		 if(average[i] > max) {
   			 max = average[i];
   		 }
   	 }
   	 for(int i = 0; i < 3; i++) {
   		 if(average[i] == max) {
   			 System.out.println("Trainee Number : " + (i + 1));
   		 }
   		 if(average[i] <70) {
   			 System.out.print("Trainee is Unfit");
   		 }
   	 }
    }

}
trainee = [[],[],[],[]]
for i in range(3):
	for j in range(3):
    		trainee[i].append(int(input()))
    		if (trainee[i][-1]) not in range(1,101):
        			print("invalid input")
for i in range(3):
	trainee[3].append((trainee[2][i]+trainee[1][i]+trainee[0][i])//3)
maximum = max(trainee[3])
for i in range(3):
	if trainee[3][i] < 70 :
    		print("Trainee {0} is unfit".format(i+1))
	elif trainee[3][i] == maximum:
    		print("Trainee Number: ",i+1)

TCS NQT coding questions 2021

218 thoughts on “TCS NQT Coding Questions 2021 with sollution”

  1. Hello there! This post couldn’t be written much better!
    Looking at this post reminds me of my previous roommate!
    He always kept preaching about this. I’ll forward this post
    to him. Pretty sure he’s going to have a great read.
    Thanks for sharing!

    Reply
  2. Heya terrific website! Does running a blog similar to this require a
    great deal of work? I’ve no knowledge of programming but I was hoping to start my own blog
    soon. Anyways, if you have any recommendations or
    techniques for new blog owners please share. I know this is off subject nevertheless
    I just wanted to ask. Thanks!

    Reply
  3. You really make it appear so easy along with your presentation however I find this topic
    to be actually something that I believe I might never
    understand. It kind of feels too complicated and very wide for me.
    I am having a look ahead in your subsequent submit, I will attempt to
    get the dangle of it!

    Reply
  4. I absolutely love your site.. Excellent colors &
    theme. Did you develop this amazing site yourself?
    Please reply back as I’m wanting to create my own site and want to find out where you got this from or just what
    the theme is named. Appreciate it!

    Check out my web page Keto BHB + Review

    Reply
  5. Heya i’m for the primary time here. I came across this board and I
    in finding It really helpful & it helped me out a lot. I hope to present something again and aid others such as you helped me.

    Reply
  6. This design is spectacular! You most certainly know how to
    keep a reader entertained. Between your wit and your
    videos, I was almost moved to start my own blog (well,
    almost…HaHa!) Fantastic job. I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!

    my web site; Mermber XXL Pills

    Reply
  7. I must voice my love for your kindness supporting those
    individuals that really want guidance on this idea. Your personal commitment to passing the solution along appears
    to be remarkably interesting and have constantly allowed ladies just like me to get to their targets.
    Your amazing interesting information entails this much a person like me and additionally to my office colleagues.

    Thanks a ton; from each one of us.

    Also visit my web page … EcoHack Fuel Saver

    Reply
  8. Νice post. I wass cecking cоntinuouѕly this ᴡгbloց
    and I’m іnsρirеd! Extremely useful information particuⅼarly ttһe ultimate phase :
    ) I take care of sᥙuch information much. I used to be seeking thiѕ certain іnfo for
    a very ⅼong time. Thank you and best of luck.

    Reply
  9. It’s remarkable to pay a visit this web page and reading
    the views of all friends on the topic of this post, while I am also zealous of getting familiarity.

    Reply
  10. Fantastic web site. Plenty of useful information here.
    I am sending it to several pals ans additionally sharing in delicious.
    And of course, thanks for your sweat!

    Reply
  11. If some one wishes expert view regarding blogging and site-building afterward
    i propose him/her to pay a visit this web site, Keep up the pleasant work.

    Reply
  12. Hi there! This is kind of off topic but I need some advice from an established blog.
    Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out
    pretty fast. I’m thinking about making my own but I’m not
    sure where to start. Do you have any points or suggestions?
    Thanks

    Feel free to visit my website … http://www.goldenanapa.ru/modules.php?name=Your_Account&op=userinfo&username=AvilesCornelius

    Reply
  13. Excellent items from you, man. I’ve be mindful your stuff prior to and you’re simply too fantastic.
    I really like what you’ve bought right here, certainly like what you’re saying and the way during which you
    are saying it. You make it enjoyable and you still care
    for to keep it sensible. I can not wait to learn far more from you.
    This is really a great website.

    my web blog; Primal Testo XL Reviews

    Reply
  14. Having read this I believed it was extremely enlightening.
    I appreciate you finding the time and effort to put this short article together.
    I once again find myself personally spending a significant amount of time
    both reading and leaving comments. But so what, it
    was still worth it!

    Look at my site: BioReady Keto

    Reply
  15. I comment each time I appreciate a article on a blog
    or if I have something to add to the conversation. It’s triggered by the fire communicated in the article I browsed.
    And on this article TCS NQT Coding Questions 2021 with sollution – LMT.
    I was actually excited enough to create a comment 🙂
    I do have some questions for you if you do not mind.
    Is it simply me or do a few of the comments appear as if they are left by brain dead visitors?

    😛 And, if you are writing at other sites, I’d like
    to keep up with you. Would you make a list every one of your shared sites
    like your linkedin profile, Facebook page or twitter feed?

    Here is my web-site; diet solution program

    Reply
  16. I don’t leave many remarks, however I browsed some remarks on TCS NQT Coding Questions 2021 with sollution – LMT.
    I actually do have a couple of questions for you if you
    do not mind. Could it be simply me or does it seem
    like some of the remarks appear like they are left by
    brain dead visitors? 😛 And, if you are writing on additional
    social sites, I would like to keep up with you. Would you post please a woman list of every one
    of your social networking sites like your linkedin profile, Facebook page or twitter feed?

    Reply
  17. Great – I should certainly pronounce, impressed with your web site.
    I had no trouble navigating through all tabs and related info ended up being truly simple to do to access.

    I recently found what I hoped for before you know it
    at all. Reasonably unusual. Is likely to
    appreciate it for those who add forums or anything, site theme .
    a tones way for your client to communicate. Nice task.

    my web page: stampedblueprint.com

    Reply
  18. Hi there would you mind sharing which blog platform you’re using?
    I’m going to start my own blog in the near future but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different
    then most blogs and I’m looking for something unique.

    P.S My apologies for being off-topic but I had
    to ask!

    my homepage :: calorie shifting diet

    Reply
  19. I not to mention my friends have been going through the excellent information and facts on your web page and so all
    of the sudden I got a terrible suspicion I had not expressed respect to the website owner for
    those techniques. My boys happened to be totally warmed to read through all of them and now have sincerely been using these things.
    Thank you for indeed being considerably kind
    as well as for getting this kind of wonderful
    subject matter millions of individuals are really eager to be informed on. My
    very own sincere regret for not saying thanks to you sooner.

    Also visit my web page; pure skin care

    Reply
  20. This is the perfect webpage for anyone who wishes to understand this topic.

    You realize so much its almost tough to argue with you (not that I personally would want to?HaHa).
    You definitely put a fresh spin on a subject that has been discussed for a
    long time. Excellent stuff, just excellent!

    my homepage :: growing weed indoors

    Reply
  21. Wonderful beat ! I wish to apprentice at the same time as
    you amend your web site, how can i subscribe for a weblog site?
    The account helped me a applicable deal. I were tiny bit familiar of this your broadcast offered brilliant clear concept.

    Also visit my webpage Serena

    Reply
  22. I became honored to receive a call coming from a friend when he observed the important guidelines shared on the site.

    Examining your blog post is a real great experience.
    Thanks again for taking into account readers at all like me, and I would like for you the best of achievements as being a professional in this
    field.

    Also visit my web-site: atkins induction

    Reply
  23. Thanks a lot for giving everyone an extremely nice opportunity to read from this blog. It is often so lovely and as well , full of amusement for me personally and my office acquaintances to visit the blog at a minimum thrice in a week to read through the fresh stuff you have. And lastly, I’m just certainly astounded considering the remarkable techniques you give. Selected two ideas in this post are easily the most beneficial I have had.

    Reply
  24. I’m curious to find out what blog platform you happen to be using? I’m experiencing some small security problems with my latest blog and I would like to find something more safeguarded. Do you have any recommendations?

    Reply
  25. Awesome blog! Do you have any helpful hints for aspiring writers? I’m hoping to start my own website soon but I’m a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m completely overwhelmed .. Any tips? Many thanks!

    Reply

Leave a Comment