What is Programming in Modern C++?
This course introduces problem-solving and programming using the C++ programming language. The topics include:
- Basic programming notions. Control flow, variables, and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.
- Program design. How human beings solve problems manually. Strategies for translating manual techniques to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants.
- Programming applications. Arithmetic on polynomials, and matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed.
- Standard Library of C++. The string, vector, and map classes.
W9_Programming_Qs-1
Due on 2023-03-30, 23:59 IST
Consider the following program.
• Fill in the blank at LINE-1 to inherit from unary function.
• Fill in the blank at LINE-2 with appropriate initializer list.
• Fill in the blank at LINE-3 to override function call operator.
The program must satisfy the sample input and output.
• Fill in the blank at LINE-1 to inherit from unary function.
• Fill in the blank at LINE-2 with appropriate initializer list.
• Fill in the blank at LINE-3 to override function call operator.
The program must satisfy the sample input and output.
Solution :
#include <iostream>
#include <algorithm>
#include <vector>
struct Compute : std::unary_function<double, void> { // LINE-1
int count;
double sum;
Compute() : count(0), sum(0.0) {} // LINE-2
void operator()(double x) { count++; sum += x; } // LINE-3
}; |
W9_Programming_Qs-2
Due on 2023-03-30, 23:59 IST
Consider the following program (in C++11) that considers a number of purchases as input and find out the total expense. Fill in the blanks as per the instructions given below:
• Fill in the blank at LINE-1 with appropriate header to overload function operator.
• Fill in the blank at LINE-2 with an appropriate return statement to implement the overload function operator.
• Fill in the blank at LINE-3 with the appropriate parameter list for calling the function accumulate,
The program must satisfy the sample input and output.
• Fill in the blank at LINE-1 with appropriate header to overload function operator.
• Fill in the blank at LINE-2 with an appropriate return statement to implement the overload function operator.
• Fill in the blank at LINE-3 with the appropriate parameter list for calling the function accumulate,
The program must satisfy the sample input and output.
Solution :
struct total_expense{
double operator()(double d, purchase& p){ //LINE-1
return d + p.get_price() * p.get_qty(); //LINE-2
}
};
double get_total_expense(std::list<purchase> li, total_expense tc){
double total = accumulate(li.begin(), li.end(), 0.0, tc); //LINE-3
return total;
} |
W9_Programming_Qs-3
Due on 2023-03-30, 23:59 IST
Consider the following program (in C++11), which finds the frequency of each vowel in a given string. Fill in the blanks as per the instructions given below:
• Fill in the blank at LINE-1 with an appropriate statement to iterate over the given string str.
• Fill in the blank at LINE-2 with conditional statement to extract the vowels.
• Fill in the blank at LINE-3 with an appropriate statement to iterate over the given map vFreq, and print it.
The program must satisfy the sample input and output.
• Fill in the blank at LINE-1 with an appropriate statement to iterate over the given string str.
• Fill in the blank at LINE-2 with conditional statement to extract the vowels.
• Fill in the blank at LINE-3 with an appropriate statement to iterate over the given map vFreq, and print it.
The program must satisfy the sample input and output.
Solution :
for (auto it = str.begin(); it != str.end(); ++it) //LINE-1
if(*it == 'a' || *it == 'e' || *it == 'i' || *it == 'o' || *it == 'u') //LINE-2
vFreq[*it]++;
return vFreq;
}
void print(std::map<char, int> vFreq){
for (auto it = vFreq.begin(); it != vFreq.end(); ++it) //LINE-3
|
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of the average of the 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 THE 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.
| An Introduction To Programming Through C++ | Answers |
| Assignment 1 | Click Here |
| Assignment 2 | Click Here |
| Assignment 3 | Click Here |
| Assignment 4 | Click Here |
| Assignment 5 | Click Here |
| Assignment 6 | Click Here |
| Assignment 7 | Click Here |
| Assignment 8 | Click Here |
| Assignment 9 | Click Here |
| Assignment 10 | NA |
| Assignment 11 | NA |
| Assignment 12 | NA |
Comments
Post a Comment