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

Describe in Detail Essay▾

What is a structure?

Edit

Explanation

Define Structure in C
  • 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?

  1. main() {
  2. char c =‘’, x, convert(z);
  3. getc(c);
  4. if((c >= ‘a’) && (c ? ‘z’))
  5. x =convert(c);
  6. printf(“ %c x);
  7. }
  8. convert(z)
  9. {
  10. return z -32;
  11. }
Edit

Explanation

Compiler error

In the program

Table Shows 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.