Sail E0 Webinar

MCQs

Total Questions : 5
Question 1.

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


  1.    b->var;
  2.    b.var;
  3.    b-var;
  4.    b>var;
 Discuss Question
Answer: Option A. -> b->var;

Because in a structure pointer, the data element is declared as above only.


Question 2.

Which of the following is a properly defined structure?


  1.    struct {int a;}
  2.    struct a_struct {int a;}
  3.    struct a_struct int a;
  4.    struct a_struct {int a;};
 Discuss Question
Answer: Option D. -> struct a_struct {int a;};

The a_struct is declared as structure name and its data element is a.


Question 3.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
struct sec {
4.
int a;
5.
char b;
6.
};
7.
int main()
8.
{
9.
struct sec s ={25,50};
10.
struct sec *ps =(struct sec *)&s;
11.
cout a b;
12.
return 0;
13.
}
  1.    252
  2.    253
  3.    254
  4.    262
 Discuss Question
Answer: Option A. -> 252

In this program, We are dividing the values of a and b, printing it.
Output:
$ g++ stu5.cpp
$ a.out
252


Question 4.


What will be the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
struct ShoeType {
6.
string style;
7.
double price;
8.
};
9.
ShoeType shoe1, shoe2;
10.
shoe1.style = "Adidas";
11.
shoe1.price = 9.99;
12.
cout
  1.    Adidas $ 9.99 Adidas $ 1.11
  2.    Adidas $ 9.99 Adidas $ 9.11
  3.    Adidas $ 9.99 Adidas $ 11.11
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> Adidas $ 9.99 Adidas $ 1.11

We copied the value of shoe1 into shoe2 and divide the shoe2 value by 9, So this is the output.
Output:
$ g++ stu2.cpp
$ a.out
Adidas $ 9.99
Adidas $ 1.11


Question 5.


What is the output of this program?



1.
#include
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

  1.    19845
  2.    20000
  3.    15000
  4.    19844
 Discuss Question
Answer: Option A. -> 19845

In this program, we are just converting the given hours and minutes into seconds.
Output:
$ g++ stu1.cpp
$ a.out
Total seconds:19845


Latest Videos

Latest Test Papers