Skip to content
Related Articles

Related Articles

C | Storage Classes and Type Qualifiers | Question 17
  • Difficulty Level : Easy
  • Last Updated : 07 Mar, 2013
GeeksforGeeks - Summer Carnival Banner

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

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :