TCS Placement: Sample Questions 276 - 278 of 502

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 276

Edit

Write in Short

Short Answer▾

How do you find out if a linked-list has an end (i.e.. the list is not a cycle)

Explanation

  • You can find out by using 2 pointers.
  • One of them goes 2 nodes each time.
  • The second one goes at 1 node every time.
  • If there is a cycle, the one that goes 2 nodes each time will eventually meet the one that goes slower.

Question 277

Question

MCQ▾

A person had to multiply two numbers. Instead of multiplying by 35, he multiplied by 53 and the product went up by 540. What was the raised product?

Choices

Choice (4)

a.

1040

b.

1720

c.

780

d.

1590

Answer

d.

Explanation

  • Let two numbers be x and 35.
  • Instead of multiplying the number x by 35, person multiplies it with 53.
  • Result of this mistake is that product is raised by 540.
  • Writing in equation form,

  • The product will be

Question 278

Question

MCQ▾

Which of the following is the correct class of the object cout?

Choices

Choice (4)

a.

Ostream

b.

Iostream

c.

Ifstream

d.

Istream

Answer

a.

Explanation

  • Ostream is the correct class of the object cout.
  • This c ++ class is used for outputting information to an arbitrary device (screen, hard drive, diskette. .) from a program.
  • C ++ always has an instantiated object of class ostream called “cout”
Given the Image is Define the Ostream Class

Developed by: