Week:9 Quiz Answers(Jan 2020-Apr2020) An Introduction to Programming through C++ NPTEL 2020

  

               An Introduction To Programming Through C++


IIT Bombay.

Week 9- QUIZ ASSIGNMENT:
---------------------------------------------------------------------------------------------------------------------
Consider the following code fragment.

struct p{
  int q;
};

p r ;

1)Which of the of the following is true?
 p is a structure type
 p is a structure member
 p is a structure instance

2)Which of the of the following is true?
 q is a structure type
 q is a structure member
 q is a structure instance

3)Which of the of the following is true?
 r is a structure type
 r is a structure member
 r is a structure instance
---------------------------------------------------------------------------------------------------------------------
Consider the execution of the following piece of code.

struct cricketer{
  char name[30];
  double average;
};

cricketer C[2] = {{"Tendulkar", 57},{"Bradman",99}};

cout <<C[0].name[4];

cout <<C[1].average;

4)What will the first statement print?
Ans: u

5)What will the second statement print?
Ans: 99
---------------------------------------------------------------------------------------------------------------------
6)Which member function do I need to define if I want to allow an operation of the form p + q where p is of type P and Q of type q?
 operator+ in the definition of P
 operator+ in the definition of Q
 + in the definition of P
 + in the definition of Q

7)A public member function can only access public data members
 True
 False

-----------------------------------------------------------------------------------------------------------------
8)Consider the following code fragment

struct P{
  P(){cout <<"1";}
};

struct Q{
  P p;
  Q(){cout <<"2";}
};

int main(){
  Q q;
}

What will it print?
 1
 2
 12
 Nothing
---------------------------------------------------------------------------------------------------------------------
Consider the code fragment below

struct P{
  P *Pptr;
  int i;
};

int main(){
  P p1 = {NULL, 1};
  P p2 = {&p1, 2};
  P p3 = {&p2, 3};

  ---blank---

}

9)If ---blank--- contains   cout << p3.Pptr->i << endl;
it will print 2
 True
 False

10)If ---blank--- contains     cout << p3->Pptr->i << endl;
it will print 2
 True
 False

11)If ---blank--- contains     cout << p3.Pptr->Pptr->i << endl;
it will produce an error.
 True
 False
WEEK-9 :PROGRAMMING ASSIGNMENT 1 AND 2 CLICK ON BELOW LINK.
<<CLICK HERE FOR  WEEK 9:PROGRAMMING -01>>
<<CLICK HERE FOR  WEEK 9: PROGRAMMING-02>> FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.

No comments:

Post a Comment

If you have any problems related to solutions or any concept please let me know.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages