Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 133 - 134 of 354
Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.
Question 133
Explanation
- A structure is a user defined data type in C/C ++ .
- Groups items of possibly different types into a single type.
- Each element of a structure is called a member.
- Widely used to store a record - that is collection of related information such as student information, employee information, product information, book information etc.
- For example, a record of student can consists of student name, address, roll number and age.
SYNATX:
struct structure_name
{
⧵⧵ declaration of different data types
} ;
EXAMPLE:
struct Book
{
char name [15] ;
int price;
int page;
} ;
Question 134
Describe in Detail Essay▾
What is the output of the following program?
main() {
char c =‘’, x, convert(z);
getc(c);
if((c >= ‘a’) && (c ? ‘z’))
x =convert(c);
printf(“ %c” x);
}
convert(z)
{
return z -32;
}
Explanation
Compiler error
In the program
char c = ‘’ , x, convert (z) ; | Define the char c = blank space, declare x variable and convert (z) function with char return. |
getc (c) ; | Call getc () function but it՚s format is wrong The declaration for get () function is int getc (FILE ⚹ stream) |
if ( (c >= ‘a’ ) && (c⇐ ‘z’ ) ) | Define the if condition |
x = convert (c) ; | Definition of convert does not match declaration. |