Constants
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int n = 020;
printf("%d", n);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
020 is octal representation of 16.
- What will be the output of the following C function?
#include <stdio.h>
enum car {AstonMartin, Audi, Chevrolet, Ferrari};
enum color {Yellow = 5, Green, RedBlue, Blue};
int main()
{
enum car c = Yellow;
int i;
i = c;
printf("%d\n", i);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
c is an integer constant, hence it is compatible.
- What will be the output of the following C code?
#include <stdio.h>
#define MAX 3
enum car {AstonMartin = MAX + 1, Audi = AstonMartin + MAX};
int main()
{
enum car c = Audi;
printf("%d\n", c);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
MAX value is 3 and hence Audi will have value 4 + 3.
- What will be the output of the following C code?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
s is null terminated, but array is not null terminated.
- What will be the output of the following program:-
#include
int main() { const int a=34; int b=128; a = b; printf("%d\n",a); return 0; }
-
View Hint View Answer Discuss in Forum
const is a type specifier, when used with a data type, its value cannot be modified
Correct Option: C
Compiler marks a as read only, any attemp to modify the value will generate compiler error.