Computer ScienceNEB 2081 (MCQs)
What is the correct syntax to declare a structure in C ? a) struct b) define struct
1Answer
The correct syntax to declare a structure in C is:
struct structure_name {
data_type member1;
data_type member2;
// ...
};
Explanation:
- A structure in C is declared using the
structkeyword followed by a name (e.g.,structure_name). - The structure body is enclosed in curly braces
{}and contains member variables (data types and names). - A semicolon (
;) is required at the end of the declaration.
Incorrect options:
a) struct { }→ Missing structure name and member variables.b) define struct→ Incorrect syntax;defineis used for macros, not structures.
Example:
struct Student {
char name[50];
int roll_no;
float marks;
};
This declares a structure named Student with three members: name, roll_no, and marks.
Discussion
Loading…
More Computer Science questions
Which of the following is the purpose of using primary key in database ? a) To uniquely identify a record b) To store duplicate record c) To backup data d) To…NEB 2082 (MCQs)1A company needs to modify an existing table by adding a new column for employee email addresses. For this, which SQL command should be used ? a) CREATE b)…NEB 2082 (MCQs)1Which protocol is used for secure communication over a computer network ? a) HTTP b) FTP c) HTTPS d) TelnetNEB 2082 (MCQs)1Which control structure in JS (Java Script) is used to execute a block of code repeatedly based on a given condition ? a) For loop b) if else c) switch case…NEB 2082 (MCQs)1Select the invalid variable name in PHP. a) $name b) $ name c) $1name d) $name123NEB 2082 (MCQs)1The statement int number ( int a); is a ... a) function call b) function definition c) function declaration d) function executionNEB 2082 (MCQs)1