Search Placementyogi.com
 

The Const Keyword in C objective questions and Answers

  :: Topics ::

1

There is no difference in the folllowing declarations.

int const x=10;
const int y=10;
A. True
B. False
See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation

No explanation available. Let's Discuss

 
2

What is the output of the following program?

#include<stdio.h>
int main()
{
  int const a;
  a=100;
  printf("%d",a);
}
A.

100

B.

error: assignment of read-only variable ‘a’

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

Nowhere other than initialization can a program assign a value to a const variable. 'a' should have been initialized when it is defined.

Ex. const int a=100;

 
3

 Are the following declarations same?

int const * x=&a;
const int * y=&b;
A. Yes
B. No
See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation

No explanation available. Let's Discuss

 
4

What is the difference in the following declarations?

int const * x=&a;
int * const y=&b;
A.

Both are same.

B.

x is a constant pointer.

C.

y is a constant pointer.

D.

y is a pointer to a constant.

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

No explanation available. Let's Discuss

 
5

What is the output of the following c program?

#include<stdio.h>
void main()
{
   int a=5;
   int const *p=&a;
   printf("%d",++(*p));
}
A.

5

B.

6

C.

Compilation Error

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

p is a pointer to a "constant integer". Here we are trying to change the value of the "constant integer" that is not allowed.

 
 

Banner to LogicGuns.com

Hide Page Information

C The Const Keyword Objective Questions and Answers for Written Round Interview

Here you can find C The Const Keyword Objective Questions with answers and explanation. We have a vast collection of Objective Questions on The Const Keyword in C that will help you a lot!

Why learn C The Const Keyword?

The Const Keyword are an integral part of C and many Objective Questions in the written round are asked from this topic.In this section you can learn and practice C The Const Keyword (Objective Questions with Answers) to improve your skills in order to face the interview and clear campus and off-campus selection of TCS, Infosys, Wipro etc.

Where can I get C The Const Keyword Objective Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved C The Const Keyword Objective Questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand.Though we do not have pdf file for C The Const Keyword, We have quiz Objective Questions with answers to help you test yourself..

\n

Where can I get C The Const Keyword Interview Objective Questions and Answers (objective type, multiple choice)?

Here you can find objective type C The Const Keyword Objective Questions and answers for interview and entrance examination.Multiple Answers and true or false type Objective Questions are also provided.

How to solve C The Const Keyword problems?

You can easily solve all kind of Objective Questions based on C The Const Keyword by practicing the exercises (including shortcut The Const Keyword to solve problems) given below.