Skip to content
Related Articles

Related Articles

C | Storage Classes and Type Qualifiers | Question 17

Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021

Output?




#include <stdio.h>
  
int main(void)
{
    int i = 10;
    const int *ptr = &i;
    *ptr = 100;
    printf("i = %d\n", i);
    return 0;
}

(A) i = 100
(B) i = 10
(C) Compiler Error
(D) Runtime Error


Answer: (C)

Explanation: Note that ptr is a pointer to a constant. So value pointed cannot be changed using the pointer ptr. See Const Qualifier in C for more details.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!