Identify the errors in the following code segment and give the-00981
This subjective question is related to the book/course vu cs605 Software EngineeringII. It can also be found in vu cs605 Mid Term Solved Past Paper No. 1.
Question 1: Identify the errors in the following code segment and give the reason of errors.
main(){
int x = 10
const int *ptr = &x ;
*ptr = 5 ;
}
main(){
int x = 10
const int *ptr = &x ;
*ptr = 5 ;
}
Answer:
Int x=10….No ending semicolon. *ptr=5... Declaring a pointer to constant integer. You cannot use this pointer to change the value being pointed to.