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

PrepInsta User

as a static variable gets zero value by default

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

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

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

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

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

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

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

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

PrepInsta User

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.

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

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

PrepInsta User

register variables are stored in registers instead of memory

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

["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%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Comments