TCS NQT Variables and Registers Quiz- 1

Question 1

Time: 00:00:00
What is the output of this C code?

#include <stdio.h>
int i=10;
void main()
{
printf(“i is %d”, i);
}

10

10

1

1

Garbage Value

Garbage Value

Runtime Error

Runtime Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

as a static variable gets zero value by default

Start

Question 2

Time: 00:00:00
What is the output of this C code?

#include <stdio.h>
int *i;
int main()
{
if (i == NULL)
{
printf(“true\n”);
}
return 0;
}

true

true

true only if NULL value is 0

true only if NULL value is 0

Compile time error

Compile time error

Nothing

Nothing

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What is the output of this C code ?

#include <stdio.h>
static int i;
void main()
{
int i;
printf(“i is %d”, i);
}

Nothing

Nothing

Garbage Value

Garbage Value

Run-time Error

Run-time Error

zero

zero

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What is the output of this C code?
#include <stdio.h>
static int x = 5;
void main()
{
        x = 9;
        printf(“%d”, x);
}

9

9

4

4

5

5

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
The scope of an automatic variable is:

Within the block it appears

Within the block it appears

Within the blocks of the block it appears

Within the blocks of the block it appears

Until the end of program

Until the end of program

Within the block it appears &  Within the blocks of the block it appears.

Within the block it appears &  Within the blocks of the block it appears.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Automatic variables are allocated space in the form of a:

stack

stack

queue

queue

priority queue

priority queue

random

random

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Which of the following is a storage specifier?

enum

enum

union

union

auto

auto

volatile

volatile

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Automatic variables are stored in ?

stack

stack

data segment

data segment

register

register

heap

heap

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What is the output of this C code?

#include <stdio.h>
int main()
{
register int i = 10;
int *q = &i;
*q = 11;
printf(“%d %d\n”, i, *q);
}

Depends on whether i is actually stored in machine register

Depends on whether i is actually stored in machine register

10 10

10 10

11 11

11 11

Compile time error

Compile time error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

If you use & operator with a register variable then compiler may give an error or warning (depending upon the compiler you are using), because when we say a variable is a register, it may be stored in a register instead of memory and accessing address of a register is invalid.

Start

Question 10

Time: 00:00:00
Register storage class can be specified to global variables

True

True

False

False

Depends on the compiler

Depends on the compiler

Depends on the standard

Depends on the standard

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 11

Time: 00:00:00
Register variables reside in

stack

stack

registers

registers

heap

heap

main memory

main memory

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

register variables are stored in registers instead of memory

Start

Question 12

Time: 00:00:00
Which of the following operation is not possible in a register variable?

Reading the value into a register variable

Reading the value into a register variable

Copy the value from a memory variable

Copy the value from a memory variable

Global declaration of register variable

Global declaration of register variable

All of the mentioned

All of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Buy TCS NQT Paid Materials

Paid Materials TCS NQT

Join TCS NQT Online Classes

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%

Comments