Programming in Modern C++ Assignment 1 Answers 2022 | Week 1 Answers: QUIZXP

Programming in Modern C++ Assignment 1

Are you looking for the Answers to NPTEL Programming in Modern C++ Assignment 1? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course Programming in Modern C++ Assignment 1

What is Programming in Modern C++?

There has been a continual debate on which programming language/s to learn, to use. As the latest TIOBE Programming Community Index for August 2021 indicates – C (13%), Python (12%), C++ (7%), Java (10%), and C#(5%) together control nearly half the programming activities worldwide. Further, C Programming Language Family (C, C++, C#, Objective C etc.) dominate more than 25% of activities. Hence, learning C++ is important as one learns about the entire family, about Object-Oriented Programming and gets a solid foundation to also migrate to Java and Python as needed. C++ is the mother of most general purpose of languages. It is multi-paradigm encompassing procedural, object-oriented, generic, and even functional programming. C++ has primarily been the systems language till C++03 which punches efficiency of the code with the efficacy of OOP.

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

Below you can find the answers for Programming in Modern C++ Assignment 1

Programming in Modern C++ Assignment 1 Answers:-

Q1. Consider the following program to compare two strings.
Fill in the blank at LINE-1 and LINE-2 with appropriate conditions, such that it satisfies the given test cases.

#include <iostream>
#include <string>
using namespace std;

int scompare(string str1, string str2){
    if (str1 < str2)      // LINE-1   
        return -1;	
    else if (str1 == str2)    // LINE-2     
        return 0;
    else
        return 1;
}

Q2. Consider the following program. 

  •     Fill in the blank at LINE-1 to complete the function header, and
  •     Fill in the blank at LINE-2 to complete the return statement, such that

it satisfies the sample input and output.

#include <iostream>
#include <algorithm> 
using namespace std;

bool compare(char c1, char c2) {    // LINE-1

    return (c1 > c2);              // LINE-2  
}

???? Next Week Answers: Assignment 02 ????

quizxp telegram

Q3. Consider the following program.

  • Fill in the blanks at LINE-1 to define the function getSorted(int arr[], int n) such that it sorts the array arr[] and
  • Fill in the blanks at LINE-2 to define the function find and update(int arr[], int n, int x, int y) such that it replaces element x in arr[] by y.

The program must satisfy the sample input and output.

#include <iostream>
#include <algorithm>
using namespace std;

void getSorted(int arr[], int n){

sort(arr, arr+n); // LINE-1

}

void find_and_update(int arr[], int n, int x, int y){

replace(arr, arr+n, x, y); // LINE-2

}
quizxp telegram

For other courses answers:- Visit

For Internship and job updates:- Visit