C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Point Out Correct Statements (Q.No. 4)
4.
Which of the following statements correct about the below code?
maruti.engine.bolts=25;
maruti.engine.bolts=25;
Discussion:
10 comments Page 1 of 1.
Aash said:
5 years ago
In structure nesting the order will be Maruthi, engine, bolt so the second one engine is nested within Maruthi;
Mounisha said:
7 years ago
Thanks @Vikas.
Frank Mondesa said:
10 years ago
As you find Maruti 1st and you find Engine 2nd and bolt 3rd this shows that bolt bold is a structure inside engine and engine is also a structure inside Maruti. So the only answer is option B.
Vishnu Sankar K R said:
1 decade ago
Options C, D are surely Incorrect.
For option A , We cannot say that the bolt is a structure.It can be a member of Structure engine. So the option A is also wrong..
Option B is Correct.
Because engine is structure and which is inside maruti. Bolt is a member of maruti.
For option A , We cannot say that the bolt is a structure.It can be a member of Structure engine. So the option A is also wrong..
Option B is Correct.
Because engine is structure and which is inside maruti. Bolt is a member of maruti.
(1)
Abhayraj said:
1 decade ago
General format of accessing structure members is.
"structure variable.structure member".
Hence, here bolts must be member of structure name engine.
& structure engine is enclosed in structure maruti.
Am I right?
"structure variable.structure member".
Hence, here bolts must be member of structure name engine.
& structure engine is enclosed in structure maruti.
Am I right?
Renuka said:
1 decade ago
Here bolt is a member of engine, so we can't say that structure bolt is nested within engine.
Thats why option B only suits.
Thats why option B only suits.
(1)
Vikas said:
1 decade ago
struct maruti
{
struct engine
{
int bolt;
}
}
Initialize the value of variable bolt: maruti.engine.bolt=25;
So engine is nested struct within maruti struct .
{
struct engine
{
int bolt;
}
}
Initialize the value of variable bolt: maruti.engine.bolt=25;
So engine is nested struct within maruti struct .
(1)
Soumya shree said:
1 decade ago
Didn't understood this. Please explain it again.
N L said:
1 decade ago
First whether that pointer is it a member of the structure or is it a variable of type structure.
If its a structure variable then,
struct maruti *p;
p=(struct maruti *)malloc(struct maruti *);
If its a structure variable then,
struct maruti *p;
p=(struct maruti *)malloc(struct maruti *);
Sandeep said:
1 decade ago
How to initialize a pointer variables in structure?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers