NPTEL Programming in Modern C++ Programming Assignment August-2023 Swayam

 

W2_Programming_Qs.1

Due on 2023-08-10, 23:59 IST
Consider the following program. Fill in the blanks as per the instructions given below:
   • at LINE-1 with function header
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-07-30, 13:23 IST
Select the Language for this assignment. 
#include <iostream>
using namespace std;
 
void print(int a, int b=0) { // LINE-1
 
    int r = b + a;
 
    cout << r;
}
int main() {
 
    int a, b;
 
    cin >> a >> b;
 
    if (b < 0)
        print(a);
    else
        print(a,b);
    return 0;
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
2 3
5
5
Passed
Test Case 2
8 -2
8
8
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed



W2_Programming_Qs.2

Due on 2023-08-10, 23:59 IST
Consider the following program. Fill in the blanks as per the instructions given below.
   • at LINE-1 with appropriate function parameter,
   • at LINE-2 with appropriate statement
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-07-30, 13:24 IST
Select the Language for this assignment. 
#include <iostream>
using namespace std;
 
int Fun(int& x) { // LINE-1
 
    x = x*x; // LINE-2
 
    return x;
}
int main() {
    int x, y;
    cin >> x;
    y = Fun(x);
    cout << x << " " << y;
    return 0;
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
4
16 16
16 16
Passed
Test Case 2
2
4 4
4 4
Passed




Private Test cases used for EvaluationStatus
Test Case 1
Passed


W2_Programming_Qs.3

Due on 2023-08-10, 23:59 IST
Consider the following program. Fill in the blanks as per the instructions given below:
   • at LINE-1 with appropriate function header,
   • at LINE-2 with appropriate return statement
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-07-30, 13:24 IST
Select the Language for this assignment. 
#include <iostream>
using namespace std;
struct point {
    int x, y;
};
point operator+ ( point& pt1, point& pt2) { //LINE-1
 
    pt1.x += pt2.x;
    pt1.y += pt2.y;
 
    return pt1;    //LINE-2
}
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    point p1 = {a, b};
    point p2 = {c, d};
    point np = p1 + p2;
    cout << "(" << p1.x << ", " << p1.y << ")" << "(" << np.x << ", " << np.y << ")";
    return 0;
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
1 2 3 4
(4, 6)(4, 6)
(4, 6)(4, 6)
Passed
Test Case 2
2 4 6 8
(8, 12)(8, 12)
(8, 12)(8, 12)
Passed




Private Test cases used for EvaluationStatus
Test Case 1
Passed

No comments

JavaFX Scene Builder

  This is an article about the JavaFX Scene Builder. You will get a short introduction about the installation and usage of the software. The...