1.) Trace the Output of the code
#include
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int *p)
{
printf(""%d\n"", *p);
}
a.) 10
b.) Some garbage value
c.) Segmentation fault/Code crash
d.) Compile time error
ANSWER: c.) Segmentation fault/Code crash
#include
struct p
{
int x;
char y;
};
int main()
{
struct p p1[] = {1, 92, 3, 94, 5, 96};
struct p *ptr1 = p1;
int x = (sizeof(p1) / 3);
if (x == sizeof(int) + sizeof(char))
printf(""%d\n"", ptr1->x);
else
printf(""falsen"");
}
a.) Compile time error
b.) 1
c.) Undefined Behaviour
d.) FALSE
ANSWER: d.) FALSE
Watchdog Timer Interview Questions
Structures Unions Enumeration - Flow-control in C
C Storage Classes
Variable Function And Structure
C Viva Questions for Freshers Basics
3.) Which of the following structure declaration doesn't require pass-by-reference?
a.) struct{int a;}s; main(){ }
b.) struct temp{int a;}; main() { struct temp s; }
c.) struct temp{int a;};
main(){}
struct temp s;
d.) None of the mentioned
ANSWER: d.) None of the mentioned
CONTINUE READING » #include
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int *p)
{
printf(""%d\n"", *p);
}
a.) 10
b.) Some garbage value
c.) Segmentation fault/Code crash
d.) Compile time error
ANSWER: c.) Segmentation fault/Code crash
2.) Trace the output of the code
#include
struct p
{
int x;
char y;
};
int main()
{
struct p p1[] = {1, 92, 3, 94, 5, 96};
struct p *ptr1 = p1;
int x = (sizeof(p1) / 3);
if (x == sizeof(int) + sizeof(char))
printf(""%d\n"", ptr1->x);
else
printf(""falsen"");
}
a.) Compile time error
b.) 1
c.) Undefined Behaviour
d.) FALSE
ANSWER: d.) FALSE
Watchdog Timer Interview Questions
Structures Unions Enumeration - Flow-control in C
C Storage Classes
Variable Function And Structure
C Viva Questions for Freshers Basics
3.) Which of the following structure declaration doesn't require pass-by-reference?
a.) struct{int a;}s; main(){ }
b.) struct temp{int a;}; main() { struct temp s; }
c.) struct temp{int a;};
main(){}
struct temp s;
d.) None of the mentioned
ANSWER: d.) None of the mentioned