ABOUT THE COURSE :

Summary | |
---|---|
Course Type | Elective |
Duration | 12 weeks |
Category | Computer Science and Engineering |
Start Date | 22 Jan 2024 |
End Date | 12 Apr 2024 |
Exam Registration Ends | 16 Feb 2024 |
Exam Date | 28 Apr 2024 IST |
Assignment Solutions : Programming Assignment :
W8_Programming_Qs-1 :
Consider the program below.
• Fill in the blank at LINE-1 to specify the fourth argument of the function call, which accepts correct type of function pointer to each member function of class Computation.
• Fill in the blank at LINE-2 with appropriate return statement.
int call(Computation *obj, int x, int y, int(Computation::*fp)(int, int)){ //LINE-1
return (obj->*fp)(x,y); //LINE-2
}
W8_Programming_Qs-2 :
#include<iostream>
#include<algorithm>
#include<vector>
struct max {
max(int cnt=0, int ss=0) : cnt_(cnt), ss_(ss) {} //LINE-1
void operator() (int x ) { ss_ += x*x; ++cnt_; } //LINE-2
int cnt_; //count of element
int ss_; //sum of square of emements
};
W8_Programming_Qs-3 :
Consider the following program, which define a type plist that stores N elements. Fill in the blanks as per the instructions given below::
•Fill in the blank at LINE-1 with appropriate template definition,
• At LINE-2 implement void insert (int i, T val) function, which inserts a value at specified index; however, if the input index is > N, it throws OutOfArray exception,
• At LINE-3 implement void T peek (int i) function, which returns value of a speci- fied index. However, if the element at the specified position is negative then it thorws InvalidElement exception.
template<typename T, int N> //LINE-1
class plist{
public:
plist(){
for(int i = 0; i < N; i++)
arr_[i] = -1;
}
//LINE-2: impelement insert() function
void insert(int i, T val)
{
if ( i >= N )
throw OutOfArray();
else
arr_[i] = val;
}
//LINE-3: impelement peek() function
T peek(int i )
{
if ( arr_[i] < 0 )
throw InvalidElement();
else
return arr_[i];
}
private:
T arr_[N];
};
CRITERIA TO GET A CERTIFICATE :
- Average assignment score = 25% of 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
Follow Us