Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

TCS - C Programming Concept MCQ - Set1 https://www.simpleway2code.me/2017/10/tcs-c-programming...

TCS - C Programming Concept MCQ - Set1

1. atoi() function is used for:

convert a character string to its equivalent integer value

2. Which of the following is NOT declared in string.h ?

strptr()

3. which of the below function is NOT declared in math.h ?


and()

4. Where are the local variable stored ?

5. while declaring parameters for main, the second parameter argv should be
declared as

char * argv[]

6. A memory leak happens when


a program allocates memory in heap but forgets to be allocate it

7. what does the default header file contain?


Declarations

8. which of the below has the highest precision?

9. What will be the output ( * Star Marked Question )


477759

1 of 4 10-08-2019, 22:52
TCS - C Programming Concept MCQ - Set1 https://www.simpleway2code.me/2017/10/tcs-c-programming...

Output: NO

10. Use of ftell()

11. which of the following is used locate the end of the file ?
feof()

12. A code will be given and you will be asked which header is missing??

13. Which of the following is NOT a fundamental datatype


enum

14. a code will be given and you have to find the error.

See more TCS NQT (National Qualifier Test) C-MCQ


Questions

TCS C-MCQ Programming Set-1

TCS C-MCQ Programming Set-2

TCS C-MCQ Programming Set-3

TCS C-MCQ Programming Set-4

TCS C-MCQ Programming Set-5

REACTIONS

POSTED BY HRISHABH

2 of 4 10-08-2019, 22:52
TCS - C Programming Concept MCQ - Set1 https://www.simpleway2code.me/2017/10/tcs-c-programming...

BHUSHAN DHAWANE

Vijay Gugulothu

saumya

saumya

ankit marwaha

Hrishabh Bajaj

Unknown

Hrishabh

poovazhagan

Unknown

3 of 4 10-08-2019, 22:52
TCS - C Programming Concept MCQ - Set1 https://www.simpleway2code.me/2017/10/tcs-c-programming...

AMIT KASHYAP

4 of 4 10-08-2019, 22:52
TCS - C Programming Concept MCQ - Set 2 https://www.simpleway2code.me/2017/11/tcs-c-programming...

TCS - C Programming Concept MCQ - Set 2

1. How many times loop will executed ?


#include<stdio.h>
int main()
{
int x,y;
for(x=5;x>=1;x--)
{
for(y=1;y<=x;y++)
printf("%d\n",y);
}
}

15

2. Which of the following indicate the end of file ?

Both feof() and EOF

3. If a functions return type is not explicitly defined then it is default to ..........(in C).
int

4. Where the local variable is stored ?

Stack

5. How many times loop will executed ?


#include<stdio.h>
int main()
{
int i;
for(i=0;i<5;i++)
{
printf("Hello\n");
}
}

6. What is dangling pointer?


points to garbage value 477762

1 of 4 10-08-2019, 22:53
TCS - C Programming Concept MCQ - Set 2 https://www.simpleway2code.me/2017/11/tcs-c-programming...

7. what is the purpose of ftell ?


to get the current file position

8. What is recursion ?

function calls itself repeatedly

9. What is the similarity between enum and struct ?

can create new data types

11. How many times hello will print ?


#include<stdio.h>
int main(void)
{
int i;
for(i=0;i<5;i++);
printf("hello");
}

REACTIONS

POSTED BY HRISHABH

Vijay Gugulothu

2 of 4 10-08-2019, 22:53
TCS - C Programming Concept MCQ - Set 2 https://www.simpleway2code.me/2017/11/tcs-c-programming...

Hrishabh Bajaj

Anuska Dutta

Hrishabh Bajaj

neha pandey

heebah saleem

Unknown

heebah saleem

Tina Rathi

alok kumar

3 of 4 10-08-2019, 22:53
TCS - C Programming Concept MCQ - Set 2 https://www.simpleway2code.me/2017/11/tcs-c-programming...

Hrishabh

Anonymous

poovazhagan

Hrishabh

4 of 4 10-08-2019, 22:53
TCS - C Programming Concept MCQ - Set 3 https://www.simpleway2code.me/2018/01/tcs-c-programming...

TCS - C Programming Concept MCQ - Set 3

Ques. Which of this is used to skip one iteration:

Ques. Which of the following does not require to include math.h header file?

Ques. Which has the highest precision?

double

Ques. Choose the correct statement


while (0 == 0) { }

It will run forever

Ques. Predict the output of following code:


main()
{
int a=10,x;
x= a-- + ++a;
printf(“%d”,x);
}

20

477764

Ques. Guess the output:


main()

1 of 3 10-08-2019, 22:53
TCS - C Programming Concept MCQ - Set 3 https://www.simpleway2code.me/2018/01/tcs-c-programming...

{
printf(“%d”,sizeof('a'));
//same as → sizeof(97)

2 or 4

Question. Predict the output of following code:


main()
{

Ques. Select the missing statement?


#include<stdio.h>
long int fact(int n);
int main()
{
\\missing statement
}
long int fact(int n)
{
if(n>=1)
return n*fact(n-1);
else
return 1;
}

printf("%ld\n",fact(5));

Ques. If a function’s return type is not explicitly defined then it’s default to ______
(In C).
int

Ques. How many times the below loop will be executed?


#include<stdio.h>
int main()
{
int i;
for(i=0;i<5;i++)
printf("Hello\n");
}

2 of 3 10-08-2019, 22:53
TCS - C Programming Concept MCQ - Set 3 https://www.simpleway2code.me/2018/01/tcs-c-programming...

Chapterwise C - MCQ .

REACTIONS

POSTED BY HRISHABH

Unknown

3 of 3 10-08-2019, 22:53
TCS NQT C-MCQ Set - 4 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-4...

TCS NQT C-MCQ Set - 4

Ques 1. What will be the output of the below program if the below code is run
with three command line parameters mentioned below:

Paper Ink Pen

#include
int main(int argc, char ** argv){
char **items;
int j = 3, i;
items = argv;
for(i = 1; (i%4); i++){
int **p = &items[j];
printf("%c", **p);
j--;
}
return 0;
}

a) PIP

Ques 2. What is the data type that occupies the least storage in “C” language?
Please give the answer in the blank line: __________

char

Ques 3. Which of the following is true?


477767

1 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 4 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-4...

d) Elements of a linked-list can be accessed only sequentially.

Ques 4. Improper formation of which of the following data-structures can cause


un-intentional looping of a program that uses it

a) Linked list

Ques 5. Which of the following statements is FALSE?

Ques 6. Eesha wrote a function fact( ) in “C” language to calculate factorial of a


given number and saved the file as fact.c. She forgot to code the main function to
call this fact function. Will she be able to compile this fact.c without the main()
function?

b) No, she can not compile as the main function is required to compile any C
program file.

Ques 7. The difference between variable declaration and variable definition is:

d) Declaration associates type to the variable whereas definition gives the value
to the variable.

Ques 8. The inorder and preorder traversal of a binary tree are d b e a f c g and a
b d e c f g, respectively. The post-order traversal of the binary tree is:

a) d e b f g c a

Ques 9. How many times the below loop will be executed?

#include<stdio.h>
int main()
{
int x, y;
for(x=5;x>=1;x--)
{
for(y=1;y<=x;y++)
printf("%d\n",y);
}
}

A. 15

2 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 4 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-4...

Ques 10. The longest common subsequence (LCS) problem is the problem of finding
the longest subsequence common to a set of sequences (often just two sequences).
A subsequence is a sequence that can be derived from another sequence by
deleting some or no elements without changing the order of the remaining
elements. One form of implementation of LCS function is given below. The function
takes as input sequences X[1…m] and Y[1…n], computes the length of the Longest
common subsequence between X[1..i] and Y[1..j] for all 1<i < m and 1< j < n, and
stores it in C[i,j]. C[m,n] will contain the length of the LCS of X and Y.

function LCSLength(X[1..m], Y[1..n])


C = array(0..m, 0..n)
for i:= 0..m
C[i,0] =0
for j := 0..n
C[0,j] = 0d
for i := 1..m
for j := 1..n
if X[i] = Y[j]
C[i,j] := C[i-1, j-1] + 1
else
C[i,j] := max(C[i, j-1], C[i-1, j])
return C[m, n]

Eesha used the above algorithm to calculate the LCS length between “kitten” and
“string”. What was the result she got? Please give the answer in the blank line.
___________

See more TCS NQT (National Qualifier Test) C-MCQ


Questions

TCS C-MCQ Programming Set-1

TCS C-MCQ Programming Set-2

TCS C-MCQ Programming Set-3

TCS C-MCQ Programming Set-4

TCS C-MCQ Programming Set-5

Some Books to Read:

REACTIONS

POSTED BY HRISHABH

3 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 4 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-4...

4 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 5 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-5...

TCS NQT C-MCQ Set - 5

Ques 1. Eesha wrote a recursive function that takes the first node in a linked
list as an argument, reverses the list, returning the first Node in the result. The
pseudo code for this function is given below. However, she did not get the
correct result. In which line number did she make a mistake?

Please give the answer in the blank line: ____________

public Node reverse(Node first)


{
if (first == null) return null;
if (first.next == null) return first;
Node second = first.next;
Node rest = reverse (second);
second.next = first;
first.next = null;
return rest.next;
}

return rest

Ques. 2 What will happen if in a C program you assign a value to an array


element whose subscript exceeds the size of array?

C. The program may crash if some important data gets overwritten.

Explanation

477767

Ques 3. What does the following declaration mean?

int (*ptr)[10];

1 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 5 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-5...

B. ptr is a pointer to an array of 10 integers

Ques 4. In C, if you pass an array as an argument to a function, what actually


gets passed?

C. Base address of the array

Ques 5. What will be the output of the program?

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

C. 3, 2, 15

Explanation

2 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 5 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-5...

Ques 6. Is there any difference int the following declarations?

int fun(int arr[]);

int fun(int arr[2]);

B. No

Explanation

Ques 7. Are the expressions arr and &arr same for an array of 10 integers?

B. No

Explanation

Ques 8. Which of the fplowing statements should be used to obtain a remainder


after dividing 3.14 by 2.1?

C. rem = fmod(3.14, 2.1);

Explanation

TCS NQT (National Qualifier Test) C-MCQ Questions

3 of 4 10-08-2019, 22:53
TCS NQT C-MCQ Set - 5 https://www.simpleway2code.me/2019/06/tcs-nqt-c-mcq-set-5...

TCS C-MCQ Programming Set-1

TCS C-MCQ Programming Set-2

TCS C-MCQ Programming Set-3

TCS C-MCQ Programming Set-4

TCS C-MCQ Programming Set-5

Some Books to read:

REACTIONS

POSTED BY HRISHABH

Unknown

Hrishabh

4 of 4 10-08-2019, 22:53

You might also like