CPP

CPP

Structures has 7 Questions
The data elements in structure are also known as what?

objects
members
datas
none of the mentioned
What will be used when terminating a structure?

:
}
;
;;
Which of the following accesses a variable in structure *b?

b->var;
b.var;
b-var;
b>var;
What will happen when the structure is declared?

it will not allocate any memory
it will allocate the memory
it will be declared and initialized
none of the mentioned
The declaration of structure is also called as?

sructure creator
structure signifier
structure specifier
none of the mentioned
What is the output of this program?
  1.     #include <iostream>
  2.     #include <string.h>
  3.     using namespace std;
  4.     int main()
  5.     {
  6.         struct student {
  7.             int num;
  8.             char name[25];
  9.         };
  10.         student stu;
  11.         stu.num = 123;
  12.         strcpy(stu.name, "John");
  13.         cout << stu.num << endl;
  14.         cout << stu.name << endl;
  15.         return 0;
  16.     }

123 john
john john
compile time error
none of the mentioned
What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     struct Time {
  4.         int hours;
  5.         int minutes;
  6.         int seconds;
  7.     };
  8.     int toSeconds(Time now);
  9.     int main()
  10.     {
  11.         Time t;
  12.         t.hours = 5;
  13.         t.minutes = 30;
  14.         t.seconds = 45;
  15.         cout << "Total seconds: " << toSeconds(t) << endl;
  16.         return 0;
  17.     }
  18.     int toSeconds(Time now)
  19.     {
  20.         return 3600 * now.hours + 60 * now.minutes + now.seconds;
  21.     }

19845
20000
15000
19844