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. Then, why should I learn it if my primary focus is on applications? This is where the recent updates of C++, namely, C++11 and several later offer excellent depths and flexibility for C++ that no language can match. These extensions attempt to alleviate some of the long-standing shortcomings for C++ including porous resource management, error-prone pointer handling, expression semantics, and better readability. The present course builds up on the knowledge of C programming and basic data structure (array, list, stack, queue etc.) to create a strong familiarity with C++98 / C++03. Besides the constructs, syntax and semantics of C++ (over C), we also focus on various idioms of C++ and attempt to go to depth with every C++ feature justifying and illustrating them with several examples and assignment problems. On the way, we illustrate various OOP concepts. The course also covers important advances in C++ 11 and later released features..
Programming In Modern C++ Week3 Programming Assignment 2023.
INTENDED AUDIENCE : Any interested audience
PREREQUISITES : 10th standard/high school
INDUSTRY SUPPORT : Programming in C++ is so fundamental that all companies dealing with systems as well as application development (including web, IoT, embedded systems) have a need for the same. These include – Microsoft, Samsung, Xerox, Yahoo, Oracle, Google, IBM, TCS, Infosys, Amazon, Flipkart, etc. This course would help industry developers to be up-to-date with the advances in C++ so that they can remain at the state-of-the-art.
Course Layout
Programming Assignment Q1 July 2023
#include
#include
using namespace std;
class Point{
const int x,y;
public:
Point(int _x=0, int _y=0) : x(_x), y(_y) {} //LINE-1
Point(const Point& p) : x(p.x), y(p.y) {} //LINE-2
double distance(Point p){
return abs(x - p.x) + abs(y - p.y); //LINE-3
}
void print(){ cout << "(" << x << "," << y << ")" << endl; }
};
int main(){
int x1,x2,y1,y2;
cin >> x1 >> y1 >> x2 >> y2;
Point p1(x1,y1), p2(x2,y2);
p1.print();
p2.print();
cout << "Distance: " << p1.distance(p2);
return 0;
}
Programming Assignment Q2 July 2023
#include
using namespace std;
class Array{
int *arr;
int size;
public:
Array(int n) : size(n), arr(new int[size]) {} //LINE-1
~Array(){ delete[] arr; } //LINE-2
void Enter(){
for(int i=0;i> arr[i];
}
void FindMin(){
int min = 999;
for(int i=0;i arr[i])
min = arr[i];
}
cout << "Min: " << min;
}
};
int main(){
int n;
cin >> n;
Array a(n);
a.Enter();
a.FindMin();
return 0;
}
Programming Assignment Q3 July 2023
#include
using namespace std;
class Student{
const int sid;
string sname;
mutable int marks; //LINE-1
public:
Student(int a, string b, int c) : sid(a), sname(b), marks(c) {}
void updateMarks(int x) const { marks += x; } //LINE-2
void print() const { //LINE-3
cout << sid << " : " << sname << " : " << marks;
}
};
int main(){
string n;
int i, m, u;
cin >> i >> n >> m >> u;
const Student s1(i, n, m);
s1.updateMarks(u);
s1.print();
return 0;
}