<AptiCode/>

Question 580: What will be the output of the program?#include<stdio.h> int main() { const int x=5; const int *ptrx; ptrx = &x; *ptrx = 10; printf("%d\n", x); return 0; }

tcs
wipro
infosys
general
aptitude
const

Step 1:const int x=5;The constant variablexis declared as an integer data type and initialized with value '5'.Step 2:const int *ptrx;The constant variableptrxis declared as an integer pointer.Step 3:ptrx = &x;The address of the constant variablexis assigned to integer pointer variable ptrx.Step 4:*ptrx = 10;Here we are indirectly trying to change the value of the constant vaiablex. This will result in an error.To change the value ofconstvariablexwe have to use*(int *)&x = 10;