• Tidak ada hasil yang ditemukan

Week 7 Quiz - Nptel

N/A
N/A
Protected

Academic year: 2024

Membagikan "Week 7 Quiz - Nptel"

Copied!
6
0
0

Teks penuh

(1)

X

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL)

» An Introduction To Programming Through C++

(course)

Unit 9 - Week 7

(https://swayam.gov.in)

(https://swayam.gov.in/nc_details/NPTEL)

[email protected]

Announcements (announcements) About the Course (https://swayam.gov.in/nd1_noc20_cs53/preview) Ask a Question (forum) Progress (student/home) Mentor (student/mentor)

Course outline

How does an NPTEL online course work?

Week 0 Week 1 Week 2 Week 3 Week 4 Week 5 Week 6

Week 7 Lecture 15 : Array Part-1 : Part 1 : Introduction (unit?

unit=92&lesson=98) Lecture 15 : Array Part-1 : Part 2 : Marks

Due on 2020-03-18, 23:59 IST.

1 point 1)

Week 7 Quiz

The due date for submitting this assignment has passed.

As per our records you have not submitted this assignment.

Suppose at the beginning of my main program I have the following declarations.

double vx[50],vy[50],z;

Given the above declarations, which of the following statement(s) contain an error?

vx[10] = vy[15];

vx = vy;

z = vy[50];

z[0] = vx[10];

No, the answer is incorrect.

Score: 0

Accepted Answers:

vx = vy;

z = vy[50];

z[0] = vx[10];

Consider the following program fragment.

int a[5];

for (int i=0; i<5; i++) cin >> a[i];

int s = 0;

for (int i=0; i<4; i++) s = s + a[i];

if (s == a[4]) cout <<1;

else cout <<0;

(2)

averaging problem (unit?

unit=92&lesson=99) Lecture 15 : Array Part-1 : Part 3 : Histogram computation (unit?

unit=92&lesson=100) Lecture 15 :

Array Part-1 : Part 4 : Marks display variation (unit?

unit=92&lesson=101) Lecture 15 :

Array Part-1 : Part 5 : Polynomial multiplication (unit?

unit=92&lesson=102) Lecture 15 :

Array Part-1 : Part 6 : Queues in dispatching taxis (unit?

unit=92&lesson=103) Lecture 15 :

Array Part-1 : Part 7 : More efficient Queues in dispatching taxis (unit?

unit=92&lesson=104) Lecture 15 :

Array Part-1 : Part 8 : Disk intersection (unit?

unit=92&lesson=105) Lecture 15 :

Array Part-1 : Part 9 : Arrays of graphical objects and conclusion (unit?

unit=92&lesson=106) Lecture 16 :

Array Part-2 : Part 1 : Introduction (unit?

unit=92&lesson=107) 2)

1 point 3)

1 point 1 point 4)

5)

What does the above program print for the input 10 20 -30 5 5?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 1

What does the above program print for the input 10 20 30 5 5?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 0

Which statements are true regarding the above program?

If the input consists of an increasing sequence of positive integers the program will always print 1.

If the input consists of an increasing sequence of positive integers the program will sometimes print 1 and sometime 0.

If the input consists of a decreasing sequence of positive integers the program will always print 0.

If the input consists of a decreasing sequence of positive integers the program will sometimes print 1 and sometime 0.

No, the answer is incorrect.

Score: 0

Accepted Answers:

If the input consists of an increasing sequence of positive integers the program will sometimes print 1 and sometime 0.

If the input consists of a decreasing sequence of positive integers the program will always print 0.

In the lectures, we saw a program that reads roll numbers and corresponding marks, and then subsequently prints marks given a roll number. The code below does the same thing, but without having the bool variable 'found' which was present in the code given in the lecture. Also note that the variable i is declared differently, see comment.

int main(){

int rollno[100]; double marks[100];

for(int i=0; i<100; i++) cin >> rollno[i] >> marks[i];

while(true){

int r; cin >> r; // read in query roll number if(r == -1) break;

int i; // i declared outside loop for(i=99; i>=0; i--){

if(rollno[i] == r){

cout << marks[i] << endl;

break;

} }

if(i == ___) cout << "Roll number not found.\n";

}

(3)

Week 8 Week 9 Week 10 Week 11 Week 12 Text Transcripts

Lecture 16 : Array Part-2 : Part 2 : Interpretation of aname[index]

(unit?

unit=92&lesson=108) Lecture 16 :

Array Part-2 : Part 3 : Arrays and function calls (unit?

unit=92&lesson=109) Lecture 16 :

Array Part-2 : Part 4 : A function to sort an array (unit?

unit=92&lesson=110) Download

Videos (unit?

unit=92&lesson=183) Weekly

Feedback (unit?

unit=92&lesson=195) Quiz : Week 7 Quiz

(assessment?

name=203) Week 7 Programming Assignment 1

(/noc20_cs53/progassignment?

name=204) Week 7 Programming Assignment 2

(/noc20_cs53/progassignment?

name=205) Week 7 Programming Assignment 3

(/noc20_cs53/progassignment?

name=206)

1 point 6)

1 point

1 point 7)

8) }

What value should be in the blank so that the code works as described above?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) -1

Suppose I use the program given in the lectures to multiply a degree 5 polynomial by a degree 10 polynomial. Note that a degree n polynomial has n+1 coefficients. Then the number of multiplications (between polynomial coefficients) performed is?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 66

Suppose I am given an array x[20]. The following code is meant to determine if there exist distinct i,j,k such that x[i]+x[j]+x[k]=0. It is expected to print True (which is printed as 1 on some computers) if such a triple exists, and False (which is printed as 0 on some computers) otherwise.

bool sum0found = false for(int i=19; i>=0; i--) for(int j=j1; j>=0; j--) for(int k=k1; k>=0; k--) if (x[i] + x[j] + x[k] == 0){

sum0found = true;

break;

}

cout << sum0found;

Which of the following values should I use for j1 and k1? Note that I want the program to be correct and also not do unnecessary work.

Use j1=19, k1=19 Use j1=i, k1=j Use j1=i+1, k1=j+1 Use j1=i-1,k1=j-1 No, the answer is incorrect.

Score: 0

Accepted Answers:

Use j1=i-1,k1=j-1

Suppose all the elements of x are positive except for x[19]. Then I can modify one of the loop bounds in the above code - so that the program gives the correct answer but the number of times the condition x[i]+x[j]+x[k] ==0 is checked, reduces considerably. How many times is the condition checked in the worst case after the modification?

(4)

1 point

9)

1 point 10)

1 point 11)

1 point No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 171

Consider the following code fragment.

int q[4]={25,26,27,28};

Assume q[0] is stored at address 2000. Also assume that each int is 4 bytes wide, so q[1] will be stored at 2004, q[2] at 2008 and so on. Note that normally when you print an address, it will get printed in hexadecimal; but just for the exercises below assume that addresses are also printed in decimal.

For each of the following statements, give what is printed. For the questions below, give your answer as a decimal number. If you think the question cannot be answered, respond by writing -1.

cout << q;

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 2000

cout << q[1];

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 26

cout << &q[3];

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: Numeric) 2012

The function below is supposed to print the sum of the array passed to it.The main program calls the function to get the sum of the elements of the array A.

int amax(int A[], int n){ // precondition n > 0 if(n==1) return blank1;

return blank2 + amax(A,n-1);

}

int main(){

int A[5]={25,61,0,3,7};

(5)

1 point 12)

13)

1 point 14)

1 point 15)

1 point cout << amax(blank3,blank4)<<endl;

}

The following questions ask you about the values to fill in the blanks.You are expected to give simplest possible values, i.e. if your answer is an expression that can be simplified, give the simplified answer, do not put any spaces in your answer. Also do not use '&' or '*' (pointer 'dereferencing') in your answer. Using subscripts ([]) is fine.

What value you can fill for blank1?

A[0]

A[n]

5 0

No, the answer is incorrect.

Score: 0

Accepted Answers:

A[0]

What value you can fill for blank2?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: String) A[n-1]

What value you can fill for blank3?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: String) A

What value you can fill for blank4?

No, the answer is incorrect.

Score: 0

Accepted Answers:

(Type: String) 5

(6)

Referensi

Dokumen terkait

Cohesive soil Cohesionless soil Boulder All of the mentioned Accepted Answers: Boulder The type of boring method that can be used for both rock and soils are________ Shell boring

Score: 0 Accepted Answers: Option b : They would have the same total depth of teeth During turning on the lathe, machining time can be halved while retaining same surface finish if

Score: 0 Accepted Answers: b 0.01% Which one is not true for TDMA algorithm a It uses recursive relation b The number of operations are usually less than Gauss elimination c TDMA

Score: 0 Accepted Answers: d a,b,c are all zero If A has all independent column, what can be said A.x=b a Unique solution b Solution exists for certain condition of b c Infinite

Accepted Answers: a Pressure is lower but velocity is

Accepted Answers: c The reverse saturation current is a function of both light falling on the junction and the junction temperature... c Refractive Index RI of the core material is

Score: 0 Accepted Answers: Hanging wall, Foot wall Seismic zonation __________ is designated to Himalayan mountain belt and the most devastating earthquake till date in this region

Score: 0 Accepted Answers: Sonication, Depletion, Protein precipitation, Quantification Which of the following statement is NOT correct for 2-DE rehydration process?. Salts are