Structures
- Which of the following uses structure?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Linked Lists, Array of structures and Binary Tree uses structure.
- What is the correct syntax to declare a function fun() which receives an array of structure in function?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
void fun(struct *num);
- What will be the output of the following C code? (Assuming size of int be 4)
#include <stdio.h>
struct Count
{
int n1;
int n2;
int n3;
} cnt[] = {0};
main()
{
printf("%d", sizeof(cnt));
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
12
- What will be the output of the following C code?
#include <stdio.h>
struct Employee
{
char *name;
};
struct Employee emp[2];
void main()
{
emp[0].name = "Ajit";
emp[1] = emp[0];
printf("%s %s", emp[0].name, emp[1].name);
emp[1].name = "Sujit";
printf(" %s %s", emp[0].name, emp[1].name);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Ajit Ajit Ajit Sujit
- What will be the output of the following C code?
#include <stdio.h>
struct Worker
{
char *name;
};
struct Worker w1[2], w2[2];
void main()
{
w1[0].name = "Imaraj";
w1[1] = w1[0];
w2 = w1;
printf("%s%s", w2[0].name, w2[1].name);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Compilation Error
main.c: In function ‘main’:
main.c:11:12: error: assignment to expression with array type
w2 = w1;