C Programming - Const - Discussion
Discussion Forum : Const - Point Out Errors (Q.No. 6)
6.
Point out the error in the program.
#include<stdio.h>
int main()
{
const int k=7;
int *const q=&k;
printf("%d", *q);
return 0;
}
Answer: Option
Explanation:
No error. This will produce 7 as output.
Discussion:
5 comments Page 1 of 1.
Reddy priya said:
9 years ago
I think it does not produce error it's just a warning and the output is 7.
Rashi said:
9 years ago
I have also tried this one in dev C++. It will give error. But how do we know where we have to run this program. It must have to mention over there.
Akash said:
10 years ago
I have also same output, it will give error.
[Error] invalid conversion from 'const int*' to 'int*' [-f permissive].
[Error] invalid conversion from 'const int*' to 'int*' [-f permissive].
Mohammad Mohsin said:
10 years ago
Given program will produce output like [Error] invalid conversion from 'const int*' to 'int*' in Dev CPP.
Mohini said:
1 decade ago
thats ok,as we are not changing the value of k
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers