1. How will you change the value of a constant variable in C?
Answer:�Constant can be changed by using the pointer. Initialize a pointer to point to the value of a and then change the value using the pointer.�
#include<stdio.h>
int main()
{
const int = 5;
printf("%d", a);
int *k = (int *) &a;
*k = 10;
printf("%d", *k);
printf("%d", a);
return 0;
}
2. What is the output of the following program?
#define SQR(x) (x*x)
main()
{
int a, b = 3;
a = SQR(b + 2);
printf("%d", a);
}
a) 25
b) 11
c) Error
d) Garbage Value
Answer: b) 11.
Since it passes like (3+2) to #define, where it calculates as (3+2 * 3+2), as 1st preference is multiply & then addition, it evaluates as (3+ 2 * 3 +2) = (3+6+2)=11.
main()
{
if ((1 || 0) && (0 || 1)) {
printf("OK I am done.");
} else {
printf("OK I am gone.");
}
}
a) none of the above
b) compile error
c) OK I am gone
d) OK I am done
Answer: d)
((1 || 0) && (0 || 1)) will be:
(( 1 ) && ( 1 ))
(1 && 1) =>1: so will print: OK I am done.
4. What is the difference between structure & union?
Answer :1. Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members.
2. In union, one block is used by all the member of the union but in case of structure, each member has its own memory space.
3. Union is best in the environment where memory is less as it shares the memory allocated. But structure cannot be implemented in shared memory.
4. As memory is shared, ambiguity is more in union, but less in structure.
5. Self-referential union cannot be implemented in any data structure, but self-referential structure can be implemented.
5. What is a wild pointer?
Answer:Wild pointer is a pointer that doesn't point to either a valid object (of the indicated type, if applicable), or to a distinguished null value, if applicable.
C Programming Basic Questions
Array in�Embedded C
C Programming�Viva�Questions
Dangling and Wild Pointers
Variables and Pointers Volatile Or Constant
C Questions for Job Interview
CONTINUE READING �
Answer:�Constant can be changed by using the pointer. Initialize a pointer to point to the value of a and then change the value using the pointer.�
#include<stdio.h>
int main()
{
const int = 5;
printf("%d", a);
int *k = (int *) &a;
*k = 10;
printf("%d", *k);
printf("%d", a);
return 0;
}
2. What is the output of the following program?
#define SQR(x) (x*x)
main()
{
int a, b = 3;
a = SQR(b + 2);
printf("%d", a);
}
a) 25
b) 11
c) Error
d) Garbage Value
Answer: b) 11.
Since it passes like (3+2) to #define, where it calculates as (3+2 * 3+2), as 1st preference is multiply & then addition, it evaluates as (3+ 2 * 3 +2) = (3+6+2)=11.
3. What is the output of the following code?
main()
{
if ((1 || 0) && (0 || 1)) {
printf("OK I am done.");
} else {
printf("OK I am gone.");
}
}
a) none of the above
b) compile error
c) OK I am gone
d) OK I am done
Answer: d)
((1 || 0) && (0 || 1)) will be:
(( 1 ) && ( 1 ))
(1 && 1) =>1: so will print: OK I am done.
4. What is the difference between structure & union?
Answer :1. Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members.
2. In union, one block is used by all the member of the union but in case of structure, each member has its own memory space.
3. Union is best in the environment where memory is less as it shares the memory allocated. But structure cannot be implemented in shared memory.
4. As memory is shared, ambiguity is more in union, but less in structure.
5. Self-referential union cannot be implemented in any data structure, but self-referential structure can be implemented.
5. What is a wild pointer?
Answer:Wild pointer is a pointer that doesn't point to either a valid object (of the indicated type, if applicable), or to a distinguished null value, if applicable.
C Programming Basic Questions
Array in�Embedded C
C Programming�Viva�Questions
Dangling and Wild Pointers
Variables and Pointers Volatile Or Constant
C Questions for Job Interview
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :