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

 

W1_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 stack declaration,
    • at LINE-2 to push values into stack,
    • at LINE-3 with appropriate statement
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-07-23, 18:53 IST
Select the Language for this assignment. 
#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
 
 
int main() {
    char str[20];
    char ch;
    cin >> str;
stack<char>s ; //LINE-1
 
    for(int i = 0; i < strlen(str); i+=2)
        s.push(str[i]); //LINE-2
 
    int len = s.size();
 
    for(int i = 0; i < len; i++) {
 
        ch = s.top();  //LINE-3
cout << ch;
 
        s.pop();
    }
    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
computer
eumc
eumc
Passed
Test Case 2
programming
gimrop
gimrop
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed



W1_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 header statement,
    • at LINE-2 with appropriate statement to calculate Euclidean distance
such that it will satisfy the given test cases.
Your last recorded submission was on 2023-07-23, 19:07 IST
Select the Language for this assignment. 
#include <iostream>
#include <cmath>     //LINE-1 
 
using namespace std;
 
struct point{
    int x, y;
};
 
double get_len(point p1, point p2){
    return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y)) ;    //LINE-2
}
int main() { 
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    point p1, p2;
    p1.x = x1;
    p1.y = y1;
    p2.x = x2;
    p2.y = y2;
    cout << round(get_len(p1, p2));
    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 3 6 9
6
6
Passed
Test Case 2
2 5 3 9
4
4
Passed





Private Test cases used for EvaluationStatus
Test Case 1
Passed


W1_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-23, 19:08 IST
Select the Language for this assignment. 
#include <iostream>
#include <algorithm>
using namespace std;
 
 
 
bool max_str(string c1, string c2) {    //LINE-1
 
    return c1 > c2;            //LINE-2
}
int main() {
    std::string words[3], word;
    for(int i = 0; i < 3; i++){
        cin >> word;
        words[i] = word;
    }
    sort(words, words + 3, max_str);
    for (int i = 0; i < 3; i++)
        cout << words[i] << " ";
    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
hello hi bye
hi hello bye
hi hello bye 
Passed after ignoring Presentation Error
Test Case 2
soumen arup himadri
soumen himadri arup
soumen himadri arup 
Passed after ignoring Presentation Error





Private Test cases used for EvaluationStatus
Test Case 1
Passed


No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...