Variables
- Which of the following format identifier can never be used for the variable var?
#include <stdio.h>
int main()
{
char *variable = "Advanced Training in C by interviewmania.com";
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
%c can be used to print the indexed position.
%d can still be used to display its ASCII value.
%s is recommended.
%f cannot be used for the variable var.
- Which of the following declaration is not supported by C?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
It is legal in Java, but not in C.
- Which of the following cannot be a variable name in C?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
volatile is C keyword.
- What will be the output of the following C code?
#include <stdio.h>
void fun(const int *);
int main()
{
const int k = 12;
printf("%d ", k);
fun(&k);
printf("%d", k);
}
void fun(const int *k)
{
*k = 21;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Cannot change a const type value.
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
const int k = 11;
int *p = &k;
*p = 22;
printf("%d\n", k);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Changing const variable through non-constant pointers invokes compiler warning.