#include int main() { printf("NeedBook\rclass\n"); return 0; }
NeedBookclass
NeedBook class
classook
NeedBook
. What will be the output of the following C code?
#include int main() { printf("NeedBook\r\nclass\n"); return 0; }
NeedBookclass
NeedBook class
classook
NeedBook
What will be the output of the following C code? #include int main() { const int p; p = 4; printf("p is %d", p); return 0; }
p is 4
Compile time error
Run time error
p is followed by a garbage value
What will be the output of the following C code?
#include void main() { int k = 4; int *const p = &k; int r = 3; p = &r; printf("%d", p); }
Address of k
Address of r
Compile time error
Address of k + address of r
Which of the following statement is false?
Constant variables need not be defined as they are declared and can be defined later
Global constant variables are initialized to zero
const keyword is used to define constant values
You cannot reassign a value to a constant variable
What will be the output of the following C code?
#include void main() { int const k = 5; k++; printf("k is %d", k); }
k is 6
Error due to const succeeding int
Error, because a constant variable can be changed only twice
Error, because a constant variable cannot be changed
What will be the output of the following C code? #include int const print() { printf("NeedBook"); return 0; } void main() { print(); }
Error because function name cannot be preceded by const
NeedBook
NeedBook is printed infinite times
Blank screen, no output
What will be the output of the following C code? #include void foo(const int *); int main() { const int i = 10; printf("%d ", i); foo(&i); printf("%d", i);
} void foo(const int *i) { *i = 20; }
Compile time error
10 20
Undefined value
10
What will be the output of the following C code?
#include int main() { const int i = 10; int *ptr = &i; *ptr = 20; printf("%d\n", i); return 0; }