Explore topic-wise MCQs in C++ Programming.

This section includes 4 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of this program?
#include 
using namespace std;
struct second
{
int p;
char q;
};
int main()
{
struct second sec ={30,210};
struct second *ps =(struct second *)&sec;
cout << ps->p <q;
return 0;
}

A. 303
B. 304
C. F 30
D. 03 F
E. 30 F
Answer» F.
2.

What is the output of this program?
#include 
using namespace std;
struct T
{
int H;
int M;
int S;
};
int Seconds(T now);
int main()
{
T t;
t.H = 6;
t.M = 3;
t.S = 15;
cout << "Total seconds: " << Seconds(t) << endl;
return 0;
}
int Seconds(T now)
{
return 3600 * now.H + 60 * now.M + now.S;
}

A. Total seconds: 21795
B. Total seconds: 20000
C. Total seconds: 21000
D. Total seconds: 21005
E. Total seconds: 19000
Answer» B. Total seconds: 20000
3.

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

A. p>var;
B. p.var;
C. p-var;
D. p->var;
E. None of these
Answer» E. None of these
4.

The data elements in the structure are also known as what?

A. members
B. data
C. objects
D. All of above
E. None of these
Answer» B. data