MCQ Single Best Answer Not Set

QPresence of code like “s.t.b = 10” indicate

ID: #2637 Structure in C Language 9,943 views
Question Info
#2637Q ID
Not SetDifficulty
Structure in C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Syntax Error
  • B structure
  • C double data type
  • D An ordinary variable name
Correct Answer: Option B

Explanation

structure

The code "s.t.b = 10" suggests that there is a data structure or a variable named "s" which contains another data structure or variable named "t" which in turn contains a variable named "b". The code assigns the value 10 to the variable "b".

In C language, such a data structure or variable can be defined using a struct. Here is an example of how this code could be implemented in C:


struct t {
    int b;
};

struct s {
    struct t t;
};

int main() {
    struct s s;
    s.t.b = 10;
    return 0;
}

In this example, a struct "t" is defined which contains a single integer variable "b". Another struct "s" is defined which contains an instance of struct "t". In the main function, an instance of struct "s" is created and the value 10 is assigned to the variable "b" using the syntax "s.t.b = 10".

Share This Question

Challenge a friend or share with your study group.