Class 6 Exam  >  Class 6 Questions  >  Choose a correct statement about C structures... Start Learning for Free
Choose a correct statement about C structures.
  • a)
    Structure elements can be initialized at the time of declaration.
  • b)
    Structure members can not be initialized at the time of declaration
  • c)
    Only integer members of structure can be initialized at the time of declaraion
  • d)
    None of the above
Correct answer is option 'B'. Can you explain this answer?
Most Upvoted Answer
Choose a correct statement about C structures.a)Structure elements can...
struct book

int SNO=10; //not allowed
};
Free Test
Community Answer
Choose a correct statement about C structures.a)Structure elements can...
Explanation:

Structure Elements Initialization:
In C programming, a structure is a user-defined data type that allows you to combine different data types into a single entity. Each data type inside the structure is called a member.

Initializing Structure Elements:
Structure elements can be initialized at the time of declaration using the following syntax:
struct structureName variableName = {value1, value2, ..., valueN};

Example:
```c
#include

// Define a structure
struct student {
char name[50];
int age;
float marks;
};

int main() {
// Initialize structure elements
struct student s1 = {"John", 20, 85.5};
printf("Name: %s\n", s1.name);
printf("Age: %d\n", s1.age);
printf("Marks: %.2f\n", s1.marks);

return 0;
}
```

Output:
```
Name: John
Age: 20
Marks: 85.50
```

Explanation:
In the above example, a structure named "student" is defined with three members: "name" (character array), "age" (integer), and "marks" (float). The structure variable "s1" is declared and initialized with values for each member at the time of declaration itself. The initialized values are then printed using printf statements.

Correct Statement:
The correct statement about C structures is option 'B': Structure members cannot be initialized at the time of declaration.

Explanation:
In C programming, structure members cannot be directly initialized at the time of declaration. Instead, the structure variable can be initialized with values for each member.

Example:
```c
#include

// Define a structure
struct student {
char name[50];
int age;
float marks;
};

int main() {
// Initialize structure variable
struct student s1 = {"John", 20, 85.5};
printf("Name: %s\n", s1.name);
printf("Age: %d\n", s1.age);
printf("Marks: %.2f\n", s1.marks);

return 0;
}
```

Output:
```
Name: John
Age: 20
Marks: 85.50
```

Explanation:
In the above example, the structure variable "s1" is declared and initialized with values for each member using curly braces and separating the values with commas. The initialized values are then printed using printf statements.

Therefore, the correct statement is option 'B': Structure members cannot be initialized at the time of declaration.
Attention Class 6 Students!
To make sure you are not studying endlessly, EduRev has designed Class 6 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 6.
Explore Courses for Class 6 exam

Top Courses for Class 6

Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer?
Question Description
Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? for Class 6 2024 is part of Class 6 preparation. The Question and answers have been prepared according to the Class 6 exam syllabus. Information about Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? covers all topics & solutions for Class 6 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer?.
Solutions for Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Class 6. Download more important topics, notes, lectures and mock test series for Class 6 Exam by signing up for free.
Here you can find the meaning of Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer?, a detailed solution for Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? has been provided alongside types of Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Choose a correct statement about C structures.a)Structure elements can be initialized at the time of declaration.b)Structure members can not be initialized at the time of declarationc)Only integer members of structure can be initialized at the time of declaraiond)None of the aboveCorrect answer is option 'B'. Can you explain this answer? tests, examples and also practice Class 6 tests.
Explore Courses for Class 6 exam

Top Courses for Class 6

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev