TCS Placement: Sample Questions 329 - 331 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 329
Question MCQ▾
The ratio of the ages of Jaya and Ravi is . After 8 years, their ages will be in the ratio of 1: 2. What will be the difference in their present ages?
Choices
Choice (4) | |
---|---|
a. | 24 |
b. | 32 |
c. | 26 |
d. | 29 |
Answer
a.Explanation
Ratio of ages of Jaya and Ravi is .
Let Jaya՚s age = 2x and Ravi՚s age = 5x.
After 8 years, their ages will be in the ratio of .
So, Jaya՚s age yearsSo, Ravi՚s age years
We are asked to find the difference between their ages, years
Question 330
Write in Short Short Answer▾
Find the next term of the following series:
0, 6, 24,60, 120, ________
EditExplanation
First term of the series is 0, i.e..
Second term of the series is 6, i.e..
Third term of the series is 24, i.e..
Fourth term of the series is 60, i.e..
Fifth term of the series is 120, i.e..
Looking at the analogy, we can find the next term.
It will be
Question 331
Describe in Detail Essay▾
Which of the following standard C library converts a string to a long integer and reports any leftover numbers that could not be converted.
EditExplanation
- strtol () converts a string to a long integer and reports any leftover numbers that could not be converted.
- function long int strtol (const char ⚹ str, char ⚹⚹ endptr, int base) converts the initial part of the string in str to a long int value according to the given base, which must be between 2 and 36 inclusive, or be the special value 0.
- This function returns the converted integral number as a long int value, else zero value is returned.
- Example:
#include <stdio.h>
#include <stdlib.h>
int main () {
char str[30] ="123456 This is example";
char ⚹ptr;
long ret;
ret =strtol(str, &ptr, 10);
printf("The number is %ld", ret);
printf("String part is |%s|", ptr);
return(0);
}
- Output:
The number is 123456
String part is|This is example |