Programming in Modern C++| Week 1

Session: JULY-DEC 2024

Course Name: Programming in Modern C++

Course Link: Click Here

For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


Q1.Consider the following program
Fill in the blank at LINE-1 such that the output is Good Morning.
a) message.resize(12)
b) message.clear()
c) message.replace(0, 12, “Good Morning”)
d) strcpy(message, “Good Morning”)

Answer: a) message.resize(12)


Q2.Consider the following code segment.
Identify the appropriate option(s) to fill in the blank at LINE-1, such that the output is:
2 4 9 8 6 3 1

a) &arr[0], &arr[0] + 3, compare
b) arr, arr + 3, compare
c) &arr[0], &arr[0] + 2, compare
d) arr, arr+ 2, compare

Answer: a) &arr[0], &arr[0] + 3, compare
b) arr, arr + 3, compare


For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


Q3. Consider the following code segment.
What will be the output?

a) 60 15 25 35 45
b) 60 25 15 35 45
c) 60 25 35 45 15
d) 60 25 35 15 45

Answer: a) 60 15 25 35 45


Q4.Consider the following code segment.
What will be the output?

a) 10 20 30 40 50 60
b) 10 20 60 30 40 50
c) 60 30 40 50 10 20
d) 20 30 40 60 10 50

Answer: d) 20 30 40 60 10 50


For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


Q5. Consider the following code segment .
What will be the output?

a) 5 5 5 5 101 102 103 99 99 99
b) 5 5 5 5 100 101 102 103 99 99
c) 5 5 5 5 101 102 103 99 99
d) 5 5 5 5 100 101 102 103 99 99 99 99

Answer: a) 5 5 5 5 101 102 103 99 99 99


Q6. Consider the following code segment .
What will be the output?

a) ProABXYZing
b) ProABgXYZramming
c) ProABXYZmming
d) ProXYZABgramming

Answer: a) ProABXYZing


For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


Q7. Consider the following code segment .
Fill in the blank at LINE-1 such that the output is 50 20 30 40 50

a) array + 4 i
b) array + 5 i
c) arrayi-4
d) array + i 5

Answer: a) array + 4 i


Q8. Consider the following code segment.
What will be the output?

a) ABCDEKJIHGFE
b) ABCDEKJIHG
c) ABCDEJIHGF
d) ABCDEFGHIJK

Answer: a) ABCDEKJIHGFE


For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


Q9. Consider the following code segment
Identify the appropriate option/s to fill in the blank at LINE-1 such that output becomes lval 20 rval 20.
Which statement/statements is/are correct?

a) STMT-1
b) STMT-2
c) STMT-3
d) STMT-4

Answer: b) STMT-2


For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


Programming Questions

W1_Programming-Qs.1
Consider the program below.
• Fill in the blank at LINE-1 to declare a stack variable st.
• Fill in the blank at LINE-2 to push values into the stack.
• Fill in the blank at LINE-3 with the appropriate statement.
The program must satisfy the given test cases.

Solution:

Update Soon

For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


W1_Programming-Qs.2
Consider the following program.
• Fill in the blank at LINE-1 with the appropriate if statement,
• Fill in the blank at LINE-2 and LINE-3 with the appropriate return statements.
The program must satisfy the sample input and output.

Solution:

Update Soon

For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers


W1_Programming-Qs.3
Consider the program below.
• Fill in the blank at LINE-1 to include the appropriate header file to utilize the abs () function.
• Fill in the blank at LINE-2 to compute the Manhattan distance between two points pt1 and pt2 as pt1.ypt2.y+pt1.x pt2.r
The program must satisfy the given test cases.

Solution:

Update Soon

For answers or latest updates join our telegram channel: Click here to join

These are Programming in Modern C++ Week 1 Assignment 1 Nptel Answers

More Solutions of Programming in Modern C++: Click Here

More Nptel Courses: https://progiez.com/nptel-assignment-answers


Programming in Modern C++ Week 1 Assignment 1 Nptel Answers