TCS NQT Programming MCQ - 2018, 2019, 2020, 2021, 2022

   TCS NQT (National Qualifier Test) C-MCQ  Questions


TCS NQT Programming MCQ 

TCS NQT Programming MCQ - SimpleWay2Code


TCS C-MCQ Programming Set - 1


Ques 1. Which data type is most suitable for storing a number 65000 in a 32-bit system?

A )   short  ✔️
B )   int   
C )   long   
D )   double


Ques 2. All keywords in C are in

A )    LowerCase letters  ✔️
B )    UpperCase letters  
C )   CamelCase letters   
D )    None


Ques 3. Variable name resolving (number of significant characters for uniqueness of variable) depends on

A )    Compiler and linker implementations ✔️ 
B )   Assemblers and loaders implementations   
C )    C language   
D )    None


Ques 4. What is the output of this C code?

 #include <stdio.h>
 int main() {
    float x = ‘a’;
    printf(“%f”, x);
    return 0; 
 }

A )   a   
B )   run time error   
C )   a.0000000   
D )   97.000000 ✔️


Ques 5. Which of the following is not a valid C variable name?

A )   int variable_count   
B )   int number   
C )    float rate   
D )    int $main ✔️

Ques 6. Which is correct with respect to size of the datatypes?

A )   char > int > float   
B )   int > char > float   
C )   char < int < double ✔️ 
D )   double > char > int


Ques 7. Consider on following declaration: 
(i)        short i=10; 
(ii)       static i=10; 
(iii)     unsigned i=10; 
(iv)      const i=10;

A )   Only (iv) is incorrect   
B )   Only (ii) and (iv) are incorrect   
C )   Only (ii),(iii) and (iv) are correct   
D )   All are correct declaration ✔️


Ques 8. Which of the following is not a valid variable name declaration?

A )   float PI = 3.14;   
B )   double PI = 3.14;   
C )   int PI = 3.14;   
D )   #define PI 3.14; ✔️


Ques 9. The format identifier  ‘%i’  is also used for _____ data type?

A )    char  
B )    int  ✔️ 
C )    float   
D )    double


Ques 10. Which of the following is a User-defined data type?

   A )   typedef int Boolean;   
B )   typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;   
C )   struct {char name[10], int age};   
D )   all of the mentioned ✔️


Ques 11. Which of the following is true for variable names in C?

 A ) They can contain alphanumeric characters as well as special characters   
B ) It is not an error to declare a variable to be one of the keywords(like goto, static)   
C ) Variable names cannot start with a digit ✔️
D ) Variable can be of any length


Ques 12. What is the size of an int data type?

A )   4 Bytes   
B )   8 Bytes   
C )   Depends on the system/compiler ✔️ 
D )   Cannot be determined



Ques 13. Literal means ?

A )   a string.   
B )   a string constant. ✔️
C )   a character.   
D )   an alphabet.


Ques 14. What will happen if the below program is executed? 

#include <stdio.h>
 int main() { 
        int main = 3;
        printf(“%d”, main);
        return 0; 
}

A )   It will cause a compile-time error  
B )   It will cause a run-time error   
C )   It will run without any error and prints 3  ✔️ 
D )   It will experience infinite looping


Ques 15. What is the output of this C code?

#include  <stdio.h> 
int main() { 
        char chr;
        chr = 128;  
        printf(“%d\n”, chr); 
        return 0; 
}

A )   128   
B )   -128 ✔️
C )   Depends on the compiler  
D )   None of the mentioned


Ques 16. What is the output of this C code?

#include <stdio.h>
 int main() {
       int y = 10000;
       int y = 34;
      printf(“Hello World! %d\n”,y); 
      return 0;
 }

A )   Compile time error  ✔️
B )   Hello World! 34   
C )   Hello World! 1000   
D )   Hello World! followed by a junk value


Ques 17. Comment on the output of this C code? 

#include <stdio.h>
 int main() { 
        float f1 = 0.1; 
        if (f1 == 0.1) 
            printf(“equal\n”); 
       else
            printf(“not equal\n”);
 }

A )   equal   
B )   not equal ✔️
C )   Output depends on compiler   
D )   None of the mentioned


Ques 18. Which of the following cannot be a variable name in C?

A )   Volatile ✔️ 
B )   true   
C )    friend   
D )   export

Ques 19. Which is valid C expression?

A )    int my_num = 100,000;   
B )    int my_num = 100000; ✔️
C )    int my num = 1000;   
D )    int $my_num = 10000;


Ques 20. 2. What is the output of this C code?

#include <stdio.h>
 int main() { 
       printf(“Hello World! %d\n”, x);
       return 0;
 }


A )   Hello World! x;   
B )   Hello World! followed by a junk value   
C )   Compile time error ✔️  
D )   Hello World!


This Blog is Hard work !

Can you give me a treat 😌


TCS NQT Programming MCQ  - Set 2

TCS NQT Programming MCQ - SimpleWay2Code


Ques 1. In a doubly circular linked list what will be the contents of right address field of last node?

a) NULL

b) Garbage value

c) Depends on User

d) Address of first node ✅


Ques 2. Which combination of the integer variables a, b and c makes the variable m get the value 4 in the following expression? m = (a> b)? ((a>c)? a:c): (( b>c) ? b:c) ?

a) a=6, b=3, c=5

b) a=3, b=4. c=2 

c) a=5, b=4, c=5

d) a=6, b=5, c=3


Ques 3. A connected graph has 3 regions and 8 edges. Find the number of vertices.

a) 11

b) 8

c) 5

d) 7 ✅


Ques 4. When we sort the given elements by using bubble sort, then in third pass/iteration how many comparisons should we perform?

25,17,31,13,2


a) 2

b) 4

c) 1

d) 3 ✅


Ques 5. What will be output of below snippet?

class Test {

      public static void main(StringÅ¿ args) throws NullPointerException{

    int a [] = {1,2};

    System.out.println("Hello");

    System.out.println("User");

    System.out.println(a[1]); 

    }

}

O/p : ? Hello 

            User

            2


Ques 6. Suppose we initialize array like int a[5]={10,20,30};

Then what will happen?

a) First two elements will be zero

b) Last two elements will be zero ✅

c) Remaining elements will be garbage elements

d) Error message from the compiler


Ques 7. When we execute the given code which character will be printed?


int main(){

   char *name={"abc",

   "def",

   "ghi",

   "jk"};

    printf("%c",*name[2]+2); 

    return 0;

}


O/P: ? Error


Ques 8. What will be the output of below code?

import java.util.*;

public class Main

static int sample(){

           return (true ? null : 0);

}

public static void main(String[] arr){

        System.out.println(Main.sample());

}

}


a) Compile Time Error

b) Runtime ✅

c) 0

d) NULL


Explanation:

Exception in thread "main" java.lang.NullPointerException

at Main.sample(Main.java:4)

at Main.main(Main.java:7)


Ques 9. Consider following tree, what will be in order for traversal?

a)  5,6,8,9,17,10,18,20,23,24,25,29

b)  5,6,8,9,10,17,18,20,23,24,25,29 

c)  5,6,8,9,18,10,17,23,20,24.25,29

d)  5,6,8,9,10,17,20,18,23,24,25,29


Ques 10. The tool that depicts progress of tasks against time, is called as:

a)  Mentimeter

b)  Bar Chart

c)  Polygraph

d)  Gantt Chart ✅



This Blog is Hard work !

Can you give me a treat 😌



TCS C-MCQ Programming Set - 3



1. atoi() function is used for:
a)convert ASCII character to integer value
b)convert a character string to its equivalent integer value
c)gets index value of character in an array
d)converts an array of characters to array of equivalent integers

2. Which of the following is NOT declared in string.h ?
a) strlen()
b) strcpy()
c) strptr()
d) strupr()

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

a) and()
b) pow()
c) exp()
d) acos()

4. Where are the local variable stored ?

a) In a Queue
b) In stack Memory
c) In hard Disk
d) In heap Memory

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

a) char argv[]
b) char argv
c) char ** argv[]
d) char * argv[]

6. A memory leak happens when

a) a program allocates memory in heap but forgets to be allocate it
b) when an un-assigned pointer is used is freed using free function
c) when realloc() is called on a pointer that is not allocated
d) A program allocates memory in stack

7. what does the default header file contain?

a) Declarations
b) Implementations
c) Prototypes
d) All of the above

8. which of the below has the highest precision?

a) long int
b) double
c) unsigned long int
d) float

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

#include <stdio.h>
{
float f = 0.1;
if (f == 0.1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
Output: NO

10. Use of ftell()

a) return current file position
b) return end of the file
c) to move file pointer position to the begining of the file
d) to flush a file

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

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

           In my question sqrt() was used and math.h was missing

13. Which of the following is NOT a fundamental datatype

Ans will be enum

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

       In my question variable r was undefined . It was star marked question so be careful


This Blog is Hard work !

Can you give me a treat 😌

TCS C-MCQ Programming Set - 4

TCS NQT Programming MCQ - SimpleWay2Code




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);
}
}
a) 11
b) 13
c) 15
d) 10

2. Which of the following indicate the end of file ?
a) feof()
b) EOF
c) Both feof() and EOF
d) None of the mentioned

3. If a functions return type is not explicitly defined then it is default to ..........(in C).
a) int
b) float
c) void
d) error

4. Where the local variable is stored ?
a) Disk
b) Stack
c) Heap
d) Register

5. How many times loop will executed ?
#include<stdio.h>
int main()
{
int i;
for(i=0;i<5;i++)
{
printf("Hello\n");
}
}

a) 0
b) 1
c) 3
d) 5

6. What is dangling pointer?
a) points to garbage value 
b) points to function
c) Both A and B
d) None of these

7. what is the purpose of ftell ?
a)to get the current file position
b)to get the current file attribute
c)to get the current file status
d)to get the current file name

8. What is recursion ?
a) looping
b) a function calls another function repeatedly
c) a fnction calls repeatedly
d) function calls itself repeatedly

9. What is the similarity between enum and struct ?
a) can assign new values
b) can create new data types
c) nothing in common
d) they are same

10. which of the following is not a fundamental datatype?
a) Enum
b) unsigned long int
c) Long int
d) double

11. How many times hello will print ?
#include<stdio.h>
int main(void)
{
int i;
for(i=0;i<5;i++);
printf("hello");
}

a) Compilation error
b) Runtime error
c) 4
d) 1


This Blog is Hard work ! 

Can you give me a treat 😌


TCS C-MCQ Programming Set - 5

TCS NQT Programming MCQ - SimpleWay2Code


Ques.  Which of this is used to skip one iteration:
A) break
B) continue
C) goto
D) return

Ques. Which of the following does not require to include math.h header file?
A) pow()
B) rand()
C)sqrt()
D) sinh()

Ques. Which has the highest precision?
A. float
B. double
C. unsigned long int
D. Long int

Ques. Choose the correct statement
while (0 == 0) { }
A) It has syntax error as there are no statements within braces {}
B) It will run forever
C) It compares 0 with 0 and since they are equal it will exit the loop immediately
D) It has syntax error as the same number is being compared with itself

Ques. Predict the output of following code:
 main()
 {
int a=10,x;
x= a-- + ++a;
printf(“%d”,x);
 }
A) 19 ​
B) 20
C) 22 
D) 23


Ques. Guess the output:
main()
{
printf(“%d”,​sizeof('a')); 
        //same as → sizeof(97)
}

A) 2 or 4 ---
B) 1 or 3
C) Garbage value 
D) ASCII value of a
Explaination:
sizeof takes ascii value of character and determines number of bytes required by it. Ascii is number, Number is of type int. so integer requires either 2 in 16 or 4 in 32 bit machine

Question. Predict the output of following code:
main()
{
int a=b=c=d=10; 
printf(“%d,%d,%d,%d”,a,b,c,d);
}
A) Error
B) 10,10,10,10
C) Garbage Value,Garbage Value,Garbage Value,10
D) Garbage Value,Garbage Value,Garbage Value,Garbage Value
Explaination: error: ‘b’ , ‘c’, ‘d’ undeclared

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;
}

A) printf(“%ll\n",fact(5));
B) printf("%u\n",fact(5));
C) printf("%d\n",fact(5));
D) printf("%ld\n",fact(5));

Ques. If a function’s return type is not explicitly defined then it’s default to ______ (In C).
A) int
B) float
C) void
D) Error

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"); 
}

A) 5
B) 1
C) 0
D) 3

This Blog is Hard work !

Can you give me a treat 😌



Post a Comment

0 Comments