3- ( Structure s ) Choose the best answer on the following questions: (I). Which
ID: 3575483 • Letter: 3
Question
3- ( Structure s) Choose the best answer on the following questions:
(I). Which of the following accesses a variable in structure b?
A. b->var;
B. b.var;
C. *b-var;
D. b>-var;
(II). Which of the following accesses a variable in a pointer to a structure, *b?
A. b->var;
B. b.var;
C. *b-var;
D. *b>var;
(III). Which of the following is a properly defined struct?
A. struct {int a,b;}
B. struct a_struct {int a,b; }
C. struct a_struct int a,b;
D. struct a_struct {int a;};
(IV). Which properly declares a variable of struct foo?
A. struct foo;
B. struct foo var;
C. foo;
D. int foo;
(V) What is the output of this C code?
1. #include <stdio.h>
2. void main()
3. {
4. struct student
5. {
6. int no;
7. char name[20];
8. };
9. struct student s;
10. no = 8;
11. printf("%d", no);
12. }
a) Nothing
b) Compile time error
c) Junk
d) 8
How do you update the code above to correct the output.
Explanation / Answer
(I). Which of the following accesses a variable in structure b?
B. b.var;
(II). Which of the following accesses a variable in a pointer to a structure, *b?
A. b->var;
(|||)Which of the following is a properly defined struct?
D. struct a_struct {int a;};
(IV). Which properly declares a variable of struct foo?
B. struct foo var;
(V) What is the output of this C code?
#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
no = 8;
printf("%d", no);
}
ans: b) Compile time error.
we can update the above code like this
#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.