diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q1.cpp new file mode 100644 index 0000000..e0dd149 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q1.cpp @@ -0,0 +1,10 @@ +#include + +using namespace std; + +int main() +{ + cout << "Hello World"; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q2.cpp new file mode 100644 index 0000000..f42ca33 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q2.cpp @@ -0,0 +1,13 @@ +#include + +using namespace std; + +int main() +{ + cout <<"Implementation of new line\n" << "and endLine" << endl << "Displayed in the next line" << endl; + cout << "Tab \t usage" << endl; + cout << "Alarm sound will be rung \a" << endl; + cout << "Carriage\rReturn" << endl; + cout << "Carria is overwritten as cursor moves to the beginning of the line to print Return" << endl; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q3.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q3.cpp new file mode 100644 index 0000000..e82ce93 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q3.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; +namespace ns1 +{ + int value() + { + return 5; + } +} +namespace ns2 +{ + const double x = 100; + double value() + { + return 2*x; + } +} + +int main() +{ + int x=500; + // Access value function within ns1 + cout << ns1::value() << '\n'; + + // Access value function within ns2 + cout << ns2::value() << '\n'; + + // Access variable x directly + cout << ns2::x << '\n'; + + // Access local variable x + cout << x << endl; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q4.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q4.cpp new file mode 100644 index 0000000..752dedb --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q4.cpp @@ -0,0 +1,46 @@ +#include +using namespace std; + +struct Student +{ + string Name; + int roll; + float marks; + + void setStudentData() + { + cin >> Name; + + cin >> roll; + + cin >> marks; + } + + void getStudentData() + { + cout << "Name:" + << " " << Name << endl; + cout << "Roll no.:" + << " " << roll << endl; + cout << "Marks:" + << " " << marks << endl; + } +}; +int main() +{ + Student s[3]; + int i; + for (i = 0; i < 3; i++) + { + cout << "Enter details of student" << i + 1 << ":" << endl; + s[i].setStudentData(); + } + + for (int i = 0; i < 3; i++) + { + cout << "Details of student" << i + 1 << ":" << endl; + s[i].getStudentData(); + } + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q5.cpp new file mode 100644 index 0000000..749879d --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q5.cpp @@ -0,0 +1,47 @@ +#include +using namespace std; + +struct Student +{ +private: + string Name; + int roll; + float marks; +public: + void setStudentData() + { + cin >> Name; + + cin >> roll; + + cin >> marks; + } + + void getStudentData() + { + cout << "Name:" + << " " << Name << endl; + cout << "Roll no.:" + << " " << roll << endl; + cout << "Marks:" + << " " << marks << endl; + } +}; +int main() +{ + Student s[3]; + int i; + for (i = 0; i < 3; i++) + { + cout << "Enter details of student" << i + 1 << ":" << endl; + s[i].setStudentData(); + } + + for (int i = 0; i < 3; i++) + { + cout << "Details of student" << i + 1 << ":" << endl; + s[i].getStudentData(); + } + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q6.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q6.cpp new file mode 100644 index 0000000..a318b65 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 1/Q6.cpp @@ -0,0 +1,48 @@ +#include +using namespace std; + +class Student +{ +private: + string Name; + int roll; + float marks; + +public: + void setStudentData() + { + cin >> Name; + + cin >> roll; + + cin >> marks; + } + + void getStudentData() + { + cout << "Name:" + << " " << Name << endl; + cout << "Roll no.:" + << " " << roll << endl; + cout << "Marks:" + << " " << marks << endl; + } +}; +int main() +{ + Student s[3]; + int i; + for (i = 0; i < 3; i++) + { + cout << "Enter details of student" << i + 1 << ":" << endl; + s[i].setStudentData(); + } + + for (int i = 0; i < 3; i++) + { + cout << "Details of student" << i + 1 << ":" << endl; + s[i].getStudentData(); + } + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/1.cpp new file mode 100644 index 0000000..f1f00ac --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/1.cpp @@ -0,0 +1,8 @@ +#include +using namespace std; + +int main() +{ + cout<<"Hello world"; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/2.cpp new file mode 100644 index 0000000..8d5b091 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/2.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main() +{ + int num, max = 300, i, flag; + + for (num = 1; num <= max; num++) + { + flag = 0; + for (i = 2; i <= num / 2; i++) + { + if (num % i == 0) + { + flag = 1; + break; + } + } + + if (flag == 0 & num != 1) + cout<<"\t"< +using namespace std; + +int main() +{ + float c, f; + + cout << "Enter celsius degree to find temperature in fahreheit: "; + cin >> c; + f = c*1.8 + 32; + cout << "Fahreheit= " << f; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/4.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/4.cpp new file mode 100644 index 0000000..d314593 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/4.cpp @@ -0,0 +1,53 @@ +#include +using namespace std; + +int main() +{ + //if statement + int i = 10; + + if (i > 15) + { + cout << "10 is less than 15"; + } + + //if else + int j = 20; + + if (j < 15) + printf("j is smaller than 15"); + else + printf("j is greater than 15"); + + + //if else if ladder + int k = 20; + + if (k == 10) + printf("k is 10"); + else if (k == 15) + printf("k is 15"); + else if (k == 20) + printf("k is 20"); + else + printf("k is not present"); + + + //switch case + int x = 2; + switch (x) + { + case 1: + cout << "Choice is 1"; + break; + case 2: + cout << "Choice is 2"; + break; + case 3: + cout << "Choice is 3"; + break; + default: + cout << "Choice other than 1, 2 and 3"; + break; + } +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/5.cpp new file mode 100644 index 0000000..ac72f06 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 1 of set 2/5.cpp @@ -0,0 +1,101 @@ +#include +using namespace std; + +int main() +{ + //for + for (int i = 1; i <= 10; i++) + { + cout << "Hello World\n"; + } + + int i = 1; + for (; i <= 10; i++) + { + cout << "Hello World\n"; + } + + + for (; i <= 10;) + { + cout << "Hello World\n"; + } + + //while + int l = 1; + + // test expression + while (l < 6) { + cout << "Hello World\n"; + + // update expression + l++; + } + + + int m=1; + + // test expression + while (m < 6) { + cout << "Hello World\n"; + + // update expression + //m++; + } + + + + + // test expression + while (m) { + cout << "Hello World\n"; + + // update expression + //m++; + } + + //do while + int n = 2; + + do { + // Loop body + cout << "Hello World\n"; + + // Update expression + n++; + + } + // Test expression + while (n < 1); + + + int a = 2; + + do { + // Loop body + cout << "Hello World\n"; + + // Update expression + //a++; + + } + // Test expression + while (a < 1); + + int b = 2; + + do { + // Loop body + cout << "Hello World\n"; + + // Update expression + b++; + + } + // Test expression + while (b); + + + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 11 of set 2/1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 11 of set 2/1.cpp new file mode 100644 index 0000000..9c74c14 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 11 of set 2/1.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ +int x = -1; + + +try { + if (x < 0) + { + cout<<"Yes "< +using namespace std; +void divisibility() +{ + int n, d, result; + cout << "Enter value of n: " << endl; + cin >> n; + cout << "Enter the value of d: " << endl; + cin >> d; + if (d == 0) + { + throw d; + } + else + { + throw runtime_error(" Chill"); + } + result = n / d; +} +void vote() +{ + int age; + cout << "Enter yor age: " << endl; + cin >> age; + if (age <= 18) + { + throw age; + } + else + throw runtime_error(" your age is more than 18 years"); +} +void check_input_alpha() +{ + char input_char; + cout << "Enter the input: " << endl; + cin >> input_char; + if ((input_char >= 65 && input_char <= 90) || (input_char >= 97 && input_char <= 122)) + throw input_char; + else + throw runtime_error(" No digits and symbols"); +} +int main() +{ + try + { + divisibility(); + } + catch (int ex) + { + cout << "Exception: Divisibilty by zero is not possible" << endl; + } + catch (runtime_error ex) + { + cout << "Division is possible" << ex.what() << endl; + } + //vote + try + { + vote(); + } + catch (int ex) + { + cout << "Your age is :" << ex << " ,so you are not allowed to vote" << endl; + } + catch (runtime_error ex) + { + cout << "You are allowed to vote because" << ex.what() << endl; + } + //check alphabets input + try + { + check_input_alpha(); + } + catch (runtime_error ex) + { + cout << "Only Aphabets are allowed as input" << ex.what() << endl; + } + catch (char ex) + { + cout << "Entered input is alphabet" << endl; + } + //Default exception + catch (...) + { + cout << "Default exception" << endl; + } + + return 0; +} diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 11 of set 2/3.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 11 of set 2/3.cpp new file mode 100644 index 0000000..27f046a --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 11 of set 2/3.cpp @@ -0,0 +1,45 @@ +#include +#include +using namespace std; +class MyException : public exception +{ +public: + const char *what() const throw() + { + return "Attempted to divide by zero!\n"; + } +}; +int main() +{ + try + { + try + { + int x, y; + cout << "Enter the two numbers : \n"; + cin >> x >> y; + if (y == 0) + { + MyException z; + throw z; + } + else + { + cout << "x / y = " << x / y << endl; + } + } + catch (exception &e) + { + cout << e.what(); + throw; + } + } + catch (exception &e) + { + cout << "\n Try division by another number" << endl; + } + catch (...) + { + cout << "Default exception" << endl; + } +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q1.cpp new file mode 100644 index 0000000..d6a3492 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q1.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; + +class Circle +{ + + private: + double radius; + + + public: + void compute_area(double r) + { + radius = r; + + double area = 3.14*radius*radius; + + cout << "Radius is: " << radius << endl; + cout << "Area is: " << area; + } + +}; + +int main() +{ + Circle obj; + obj.compute_area(1.5); + + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q2.cpp new file mode 100644 index 0000000..6674601 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q2.cpp @@ -0,0 +1,54 @@ +#include +using namespace std; +class Complex +{ +public: + float real; + float imaginary; + + void setComplex(float a, float b) + { + real = a; + imaginary = b; + } + + void displayComplex() + { + cout << real << "+" << imaginary << "i" << endl; + } + + void sumComplex(Complex o1, Complex o2) + { + + real = o1.real + o2.real; + imaginary = o1.imaginary + o2.imaginary; + } +}; + +int main() +{ + Complex obj; + float r, i; + cout << "Enter real part of first number" << endl; + cin >> r; + cout << "Enter imaginary part of first number" << endl; + cin >> i; + obj.setComplex(r, i); + obj.displayComplex(); + + Complex obj2; + float r2, i2; + cout << "Enter real part of second number" << endl; + cin >> r2; + cout << "Enter imaginary part of second number" << endl; + cin >> i2; + obj2.setComplex(r2, i2); + obj2.displayComplex(); + + Complex R; + R.sumComplex(obj, obj2); + cout << "The sum is : "; + R.displayComplex(); + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3a.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3a.cpp new file mode 100644 index 0000000..2f02c6c --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3a.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +class A +{ +public: + void fun(); +}; + +void A::fun() +{ + cout << "fun() called"; +} + +int main() +{ + A a; + a.fun(); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3b.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3b.cpp new file mode 100644 index 0000000..aadea32 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3b.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; + +int x = 1; + +int main() +{ + int x = 10; + cout << "Value of global x is " << ::x; + cout << "\nValue of local x is " << x; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3c.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3c.cpp new file mode 100644 index 0000000..2011c52 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3c.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; + +class Test +{ + static int x; + +public: + static int y; + + void func(int x) + { + cout << "Value of static x is " << Test::x; + + cout << "\nValue of local x is " << x; + } +}; + +int Test::x = 1; +int Test::y = 2; + +int main() +{ + Test obj; + int x = 3; + obj.func(x); + + cout << "\nTest::y = " << Test::y; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3d.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3d.cpp new file mode 100644 index 0000000..aed77b8 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q3d.cpp @@ -0,0 +1,10 @@ +#include + +int main() +{ + int n; + std::cout << "Hello enter a number" << std::endl; + std::cin >> n; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q4.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q4.cpp new file mode 100644 index 0000000..a37a36a --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q4.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; +namespace ns1 +{ + int value() + { + return 5; + } +} +namespace ns2 +{ + const double x = 100; + double value() + { + return 2 * x; + } +} + +int main() +{ + int x = 500; + // Access value function within ns1 + cout << ns1::value() << '\n'; + + // Access value function within ns2 + cout << ns2::value() << '\n'; + + // Access variable x directly + cout << ns2::x << '\n'; + + // Access local variable x + cout << x << endl; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q5.cpp new file mode 100644 index 0000000..3d30034 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 2 of set 1/Q5.cpp @@ -0,0 +1,41 @@ +#include + +using namespace std; +class Line +{ +public: + void setLength(double len); + double getLength(void); + Line(); + ~Line(); + +private: + double length; +}; + +Line::Line(void) +{ + cout << "Object is being created" << endl; +} +Line::~Line(void) +{ + cout << "Object is being deleted" << endl; +} +void Line::setLength(double len) +{ + length = len; +} +double Line::getLength(void) +{ + return length; +} + +int main() +{ + Line line; + + line.setLength(6.0); + cout << "Length of line : " << line.getLength() << endl; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/1.cpp new file mode 100644 index 0000000..f1f00ac --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/1.cpp @@ -0,0 +1,8 @@ +#include +using namespace std; + +int main() +{ + cout<<"Hello world"; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/2.cpp new file mode 100644 index 0000000..8d5b091 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/2.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main() +{ + int num, max = 300, i, flag; + + for (num = 1; num <= max; num++) + { + flag = 0; + for (i = 2; i <= num / 2; i++) + { + if (num % i == 0) + { + flag = 1; + break; + } + } + + if (flag == 0 & num != 1) + cout<<"\t"< +using namespace std; + +int main() +{ + float c, f; + + cout << "Enter celsius degree to find temperature in fahreheit: "; + cin >> c; + f = c*1.8 + 32; + cout << "Fahreheit= " << f; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/4.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/4.cpp new file mode 100644 index 0000000..d314593 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/4.cpp @@ -0,0 +1,53 @@ +#include +using namespace std; + +int main() +{ + //if statement + int i = 10; + + if (i > 15) + { + cout << "10 is less than 15"; + } + + //if else + int j = 20; + + if (j < 15) + printf("j is smaller than 15"); + else + printf("j is greater than 15"); + + + //if else if ladder + int k = 20; + + if (k == 10) + printf("k is 10"); + else if (k == 15) + printf("k is 15"); + else if (k == 20) + printf("k is 20"); + else + printf("k is not present"); + + + //switch case + int x = 2; + switch (x) + { + case 1: + cout << "Choice is 1"; + break; + case 2: + cout << "Choice is 2"; + break; + case 3: + cout << "Choice is 3"; + break; + default: + cout << "Choice other than 1, 2 and 3"; + break; + } +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/5.cpp new file mode 100644 index 0000000..ac72f06 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 3 of set 1/5.cpp @@ -0,0 +1,101 @@ +#include +using namespace std; + +int main() +{ + //for + for (int i = 1; i <= 10; i++) + { + cout << "Hello World\n"; + } + + int i = 1; + for (; i <= 10; i++) + { + cout << "Hello World\n"; + } + + + for (; i <= 10;) + { + cout << "Hello World\n"; + } + + //while + int l = 1; + + // test expression + while (l < 6) { + cout << "Hello World\n"; + + // update expression + l++; + } + + + int m=1; + + // test expression + while (m < 6) { + cout << "Hello World\n"; + + // update expression + //m++; + } + + + + + // test expression + while (m) { + cout << "Hello World\n"; + + // update expression + //m++; + } + + //do while + int n = 2; + + do { + // Loop body + cout << "Hello World\n"; + + // Update expression + n++; + + } + // Test expression + while (n < 1); + + + int a = 2; + + do { + // Loop body + cout << "Hello World\n"; + + // Update expression + //a++; + + } + // Test expression + while (a < 1); + + int b = 2; + + do { + // Loop body + cout << "Hello World\n"; + + // Update expression + b++; + + } + // Test expression + while (b); + + + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1a.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1a.cpp new file mode 100644 index 0000000..51fdc86 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1a.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; + +class construct +{ +public: + int a, b; + + construct() + { + a = 10; + b = 20; + } +}; + +int main() +{ + + construct c; + cout << "a: " << c.a << endl + << "b: " << c.b; + return 1; +} diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1b.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1b.cpp new file mode 100644 index 0000000..deeeda2 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1b.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +class Friends +{ +private: + string st; + +public: + + Friends (string str)//Parameterized Constructor + { + st=str; + } + + string getst() + { + return st; + } + +}; + +int main() +{ + //Constructor called. + Friends p("Learning is fun with Friends"); + cout < +using namespace std; + +class Point +{ +private: + int x, y; + +public: + Point(int x1, int y1) + { + x = x1; + y = y1; + } + + int getX() + { + return x; + } + int getY() + { + return y; + } +}; + +int main() +{ + + Point p1(10, 15); + + cout << "p1.x = " << p1.getX() << ", p1.y = " << p1.getY(); + + return 0; +} diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1d.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1d.cpp new file mode 100644 index 0000000..7ec7027 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/1d.cpp @@ -0,0 +1,43 @@ +#include +using namespace std; + +// declare a class +class Wall +{ +private: + double length; + double height; + +public: + Wall(double len, double hgt) + { + + length = len; + height = hgt; + } + + Wall(Wall &obj) + { + + length = obj.length; + height = obj.height; + } + double calculateArea() + { + return length * height; + } +}; + +int main() +{ + + Wall wall1(10.5, 8.6); + + cout << "Area of Wall 1: " << wall1.calculateArea() << endl; + + Wall wall2 = wall1; + + cout << "Area of Wall 2: " << wall2.calculateArea() << endl; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/2.cpp new file mode 100644 index 0000000..fe4bb69 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/2.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +class Demo +{ + int X,Y; + public: + Demo() + { + X = 0; + Y = 0; + + cout << endl << "Constructor Called"; + } + Demo(int X, int Y=20) //Perameterized constructor with default argument. + { + this->X = X; + this->Y = Y; + cout<<"Constructor Called"< +using namespace std; +class HelloWorld{ +public: + //Constructor + HelloWorld(){ + cout<<"Constructor is called"< +using namespace std; + +class Date +{ + private: + short int dd, mm, yy; + + public: + Date() //constrctor: + { + dd = mm = yy = 0; + } + + void getdata(int i, int j, int k) + { + dd = i; + mm = j; + yy = k; + } + + + void prndata(void) + { + cout<<"\nData is "<prndata(); + + cout<<"\nInitializing data members using the object pointer, with values 20, 10, 2016"<getdata(20, 10, 2016); + cout<<"printing members using the object "; + D1.prndata(); + + cout<<"Printing members using the object pointer "; + dptr->prndata(); + + return 0; +} + diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/4b1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/4b1.cpp new file mode 100644 index 0000000..0416a73 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/4b1.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +/* local variable is same as a member's name */ +class Test +{ +private: +int x; +public: +void setX (int x) +{ + // The 'this' pointer is used to retrieve the object's x + // hidden by the local variable 'x' + this->x = x; +} +void print() { cout << "x = " << x << endl; } +}; + +int main() +{ +Test obj; +int x = 20; +obj.setX(x); +obj.print(); +return 0; +} diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/4b2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/4b2.cpp new file mode 100644 index 0000000..9ed4153 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/4b2.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +/* local variable is same as a member's name */ +class Test +{ +private: +int x; +public: +void setX (int x) +{ + // The 'this' pointer is used to retrieve the object's x + // hidden by the local variable 'x' + this->x = x; +} +void print() { cout << "x = " << x << endl; } +}; + +int main() +{ +Test *obj; +int x = 20; +obj->setX(x); +obj->print(); +return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/5.cpp new file mode 100644 index 0000000..2fcf402 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 1/5.cpp @@ -0,0 +1,41 @@ +//dynamic memory allocation +#include +using namespace std; +class world +{ + int*d; //pointer variable + public: + world() + { + d=new int[5]; + } + void getdata() + { + int i; + for(i=0;i<5;i++) + { + cin>>d[i]; + } + } + void display() + { + int i; + for(i=0;i<5;i++) + { + cout<<"i="<<"d="< +using namespace std; +class Obj{ + public: + int b; +}; +int main(){ + Obj *ptr[5]; + for(int i=0;i<5;i++){ + ptr[i] = new Obj; + ptr[i]->b = i; + } + for(int i=0;i<5;i++){ + cout<b< +using namespace std; +class demo +{ + public: + demo() //default constructor + { + cout<<"I am a constructor"< +using namespace std; +class B; //declared class B +class A +{ + int a; + public: + A() + { + a=20; + } + friend class B; //called;friend of class A +}; + +class B //defined class B +{ + int b; + public: + B() + { + b=10; + } + void display(A aa) + { + cout< +using namespace std; + +class rec +{ +private: + int I; + int b; + +public: + rec(int a, int c) + { + I = a; + b = c; + } + void put() + { + cout << "Area is : " << I * b << endl; + } +}; +int main() +{ + rec obj[3] = {rec(3, 6), rec(2, 5), rec(5, 5)}; + cout << "Displaying Areas of Rectangles : \n"; + for (int i = 0; i < 3; i++) + obj[i].put(); + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/2.cpp new file mode 100644 index 0000000..7018645 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/2.cpp @@ -0,0 +1,53 @@ +#include +using namespace std; + +class Employee +{ +private: + int employee_id; + char employee_name[100]; + int employee_age; + long int employee_salary; + +public: + void inputInfo() + { + cout << "Enter the Employee Id" << endl; + cin >> employee_id; + cout << "Enter the Employee name" << endl; + cin >> employee_name; + cout << "Enter the Employee age" << endl; + cin >> employee_age; + cout << "Enter the Employee salary" << endl; + cin >> employee_salary; + } + void displayInfo() + { + cout << "Employee Id:" << employee_id << endl; + cout << "Employee Name:" << employee_name << endl; + cout << "Employee age:" << employee_age << endl; + cout << "Employee salary:" << employee_salary << endl; + } +}; +int main() +{ + int i, n; + + + cout << "Enter the no. of employees" << endl; + cin >> n; + Employee emp[n]; + for (i = 0; i < n; i++) + { + cout<<"Enter the details of employee "< +using namespace std; + +class Test +{ +private: + int x; + int y; +public: + Test(int x = 0, int y = 0) { this->x = x; this->y = y; } + Test &setX(int a) { x = a; return *this; } + Test &setY(int b) { y = b; return *this; } + void print() { cout << "x = " << x << " y = " << y << endl; } +}; + +int main() +{ + Test obj1(5, 5); + + + obj1.setX(10).setY(20); + + obj1.print(); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/3b.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/3b.cpp new file mode 100644 index 0000000..1bf20a8 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/3b.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +class Test +{ +private: + int x; + +public: + void setX(int x) + { + + this->x = x; + } + void print() { cout << "x = " << x << endl; } +}; + +int main() +{ + Test obj; + int x = 20; + obj.setX(x); + obj.print(); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/4.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/4.cpp new file mode 100644 index 0000000..a7f397e --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/4.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; +int main() +{ + int i, n, s; + cout << "Enter total number of elements:" + << "\n"; + cin >> n; + int *a = new int(n); + cout << "Enter " << n << " elements" << endl; + for (i = 0; i < n; i++) + { + cin >> a[i]; + } + s = a[0]; + for (i = 1; i < n; i++) + { + if (s > a[i]) + s = a[i]; + } + cout << "\nSmallest Number = " << s; + cout << endl; + delete (a); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/5.cpp new file mode 100644 index 0000000..dbfc522 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 4 of set 2/5.cpp @@ -0,0 +1,62 @@ +#include +using namespace std; + +class Employee +{ +public: + int *employee_id; + char *employee_name; + int *employee_age; + int *employee_salary; + + Employee() + { + employee_name = new char[100]; + employee_id=new int; + *employee_id=0; + employee_age=new int; + *employee_age=0; + employee_salary=new int; + *employee_salary=0; + } + + void inputInfo() + { + cout << "Enter the Employee Id" << endl; + cin >> *employee_id; + cout << "Enter the Employee name" << endl; + cin >> employee_name; + cout << "Enter the Employee age" << endl; + cin >> *employee_age; + cout << "Enter the Employee salary" << endl; + cin >> *employee_salary; + } + void displayInfo() + { + cout << "Employee Id:" << *employee_id << endl; + cout << "Employee Name:" << *employee_name << endl; + cout << "Employee age:" << *employee_age << endl; + cout << "Employee salary:" << *employee_salary << endl; + } +}; +int main() +{ + int i, n; + + cout << "Enter the no. of employees" << endl; + cin >> n; + Employee emp[n]; + for (i = 0; i < n; i++) + { + cout << "Enter the details of employee " << i + 1 << endl; + emp[i].inputInfo(); + } + cout << "Details of Employees are:" << endl; + for (i = 0; i < n; i++) + { + cout << "Employee " << i + 1 << endl; + emp[i].displayInfo(); + } + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/1.cpp new file mode 100644 index 0000000..a76de9d --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/1.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + +class Animal +{ + +public: + void characteristics() + { + cout << "Characteristics of dog" << endl; + } + void eat() + { + cout << "Dog can eat!" << endl; + } + + void sleep() + { + cout << "Dog can sleep!" << endl; + } +}; + +class Dog : public Animal +{ + +public: + void bark() + { + cout << "Dog can bark! Woof woof!!" << endl; + } +}; + +int main() +{ + + Dog dog1; + Animal a; + + a.characteristics(); + dog1.eat(); + dog1.sleep(); + dog1.bark(); + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/2.cpp new file mode 100644 index 0000000..d92cb87 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/2.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +class Polygon { + public: + void set_value(int a, int b){ + height=a; + width=b; + } + virtual void calc_area() = 0; + protected: + int height; + int width; +}; + +class Rectangle: public Polygon { + public: + void calc_area(); +}; +void Rectangle::calc_area() { + cout << "Rectangle area: " << (height*width) << endl; +} + +int main() { + Rectangle s1; + s1.set_value(5,2); + s1.calc_area(); + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/3a.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/3a.cpp new file mode 100644 index 0000000..c4623b9 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/3a.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; + +class Base { + private: + int pvt = 1; + + protected: + int prot = 2; + + public: + int pub = 3; + + + int getPVT() { + return pvt; + } +}; + +class ProtectedDerived : protected Base { + public: + + int getProt() { + return prot; + } + + + int getPub() { + return pub; + } +}; + +int main() { + ProtectedDerived object1; + cout << "Private cannot be accessed." << endl; + cout << "Protected = " << object1.getProt() << endl; + cout << "Public = " << object1.getPub() << endl; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/3b.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/3b.cpp new file mode 100644 index 0000000..2f412b8 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/3b.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; + +class Base +{ +private: + int pvt = 1; + +protected: + int prot = 2; + +public: + int pub = 3; + + int getPVT() + { + return pvt; + } +}; + +class PrivateDerived : private Base +{ +public: + int getProt() + { + return prot; + } + + int getPub() + { + return pub; + } +}; + +int main() +{ + PrivateDerived object1; + cout << "Private cannot be accessed." << endl; + cout << "Protected = " << object1.getProt() << endl; + cout << "Public = " << object1.getPub() << endl; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/4(i).cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/4(i).cpp new file mode 100644 index 0000000..43ef2ea --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/4(i).cpp @@ -0,0 +1,21 @@ +#include +using namespace std; +class Package +{ + private: + int length; + public: + Package(): length(0) { } + friend int display(Package); +}; +int display(Package b) +{ + b.length += 10; + return b.length; +} +int main() +{ + Package b; + cout<<"Length of Package: "<< display(b)< +using namespace std; +class XYZ +{ +private: + char ch = 'A'; + int num = 11; + +public: + friend class ABC; +}; +class ABC +{ +public: + void disp(XYZ obj) + { + cout << obj.ch << endl; + cout << obj.num << endl; + } +}; +int main() +{ + ABC obj; + XYZ obj2; + obj.disp(obj2); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/5.cpp new file mode 100644 index 0000000..88cb49d --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/5.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +class Base { + public: + void print() { + cout << "Base Function" << endl; + } +}; + +class Derived : public Base { + public: + void print() { + cout << "Derived Function" << endl; + } +}; + +int main() { + Derived derived1; + derived1.print(); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/6a.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/6a.cpp new file mode 100644 index 0000000..f1f3785 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/6a.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + class Car { + public: + float Price = 60000; + }; + class Service: public Car { + public: + float insurance = 5000; + }; +int main(void) { + Service p1; + cout<<"Price: "< +using namespace std; + class Animal { + public: + void eat() { + cout<<"Eating..."< +using namespace std; +class A +{ + protected: + int a; + public: + void get_a(int n) + { + a = n; + } +}; + +class B +{ + protected: + int b; + public: + void get_b(int n) + { + b = n; + } +}; +class C : public A,public B +{ + public: + void display() + { + std::cout << "The value of a is : " < +using namespace std; +class Shape +{ +public: + int a; + int b; + void get_data(int n, int m) + { + a = n; + b = m; + } +}; +class Rectangle : public Shape +{ +public: + int rect_area() + { + int result = a * b; + return result; + } +}; +class Triangle : public Shape +{ +public: + int triangle_area() + { + float result = 0.5 * a * b; + return result; + } +}; +int main() +{ + Rectangle r; + Triangle t; + int length, breadth, base, height; + cout << "Enter the length and breadth of a rectangle: " << endl; + cin >> length >> breadth; + r.get_data(length, breadth); + int m = r.rect_area(); + cout << "Area of the rectangle is : " << m << std::endl; + cout << "Enter the base and height of the triangle: " << endl; + cin >> base >> height; + t.get_data(base, height); + float n = t.triangle_area(); + cout << "Area of the triangle is : " << n << endl; + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/6e.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/6e.cpp new file mode 100644 index 0000000..bd7ffa2 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/6e.cpp @@ -0,0 +1,56 @@ +#include +using namespace std; +class A +{ + protected: + int a; + public: + void get_a() + { + cout << "Enter the value of 'a' : " << endl; + cin>>a; + } +}; + +class B : public A +{ + protected: + int b; + public: + void get_b() + { + cout << "Enter the value of 'b' : " << endl; + cin>>b; + } +}; +class C +{ + protected: + int c; + public: + void get_c() + { + cout << "Enter the value of c is : " << endl; + cin>>c; + } +}; + +class D : public B, public C +{ + protected: + int d; + public: + void mul() + { + get_a(); + get_b(); + get_c(); + cout << "Multiplication of a,b,c is : " < +using namespace std; +class base +{ +public: + virtual void print() + { + cout << "print base class" << endl; + } + void show() + { + cout << "show base class" << endl; + } +}; +class derived : public base +{ +public: + void print() + { + cout << "print derived class" << endl; + } + void show() + { + cout << "show derived class" << endl; + } +}; +int main() +{ + + derived d; + + + d.print(); + + d.show(); +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/8.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/8.cpp new file mode 100644 index 0000000..8e4750b --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/8.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +class Base +{ + int x; + +public: + virtual void fun() = 0; + int getX() { return x; } +}; +class Derived : public Base +{ + int y; + +public: + void fun() { cout << "fun() called"; } +}; + +int main(void) +{ + Derived d; + d.fun(); + return 0; +} diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/9.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/9.cpp new file mode 100644 index 0000000..59b6ced --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 5 of set 1/9.cpp @@ -0,0 +1,72 @@ +#include + +using namespace std; + +class base + +{ + +public: + base() + + { + + cout << "\nConstructor of base class..."; + } + + ~base() + + { + + cout << "\nDestructor of base class.... "; + } +}; + +class derived : public base + +{ + +public: + derived() + + { + + cout << "\nConstructor of derived ..."; + } + + ~derived() + + { + + cout << "\nDestructor of derived ..."; + } +}; + +class derived1 : public derived + +{ + +public: + derived1() + + { + + cout << "\nConstructor of derived1 ..."; + } + + ~derived1() + + { + + cout << "\nDestructor of derived1 ..."; + } +}; + +int main() + +{ + + derived1 x; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/1.cpp new file mode 100644 index 0000000..a41f11a --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/1.cpp @@ -0,0 +1,43 @@ +#include +#include +using namespace std; +float area(float a) +{ + float eq; + eq = (sqrt(3)/4 * a*a); + return eq; +} +float area(float b, float h) +{ + return (b * h * 0.5); +} +int area(int a, int b) +{ + return (0.5 * b * (sqrt(a * a - ((b * b) / 4)))); +} +int main() +{ + float b, h,s; + int p, q; + //area of right angle triangle + cout << "\nTo find area of right angle triangle" << endl; + cout << "Base :" << endl; + cin >> b; + cout << "Height :" << endl; + cin >> h; + cout << "area of right angle triangle :" << area(b, h) << endl; + //area of isosceles triangle + cout << "\nTo find area of isosceles triangle" << endl; + cout << "length of each equal side:" << endl; + cin >> p; + cout << "Length of unequal side :" << endl; + cin >> q; + cout << "area of isosceles triangle :" << area(p, q) << endl; + //area of equilateral triangle + cout << "\nTo find area of equilateral triangle" << endl; + cout << "length of each side of equilateral triangle :" << endl; + cin >> s; + cout << "area of equilateral triangle :" << area(s) << endl; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/2.cpp new file mode 100644 index 0000000..b7e96b5 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/2.cpp @@ -0,0 +1,75 @@ +#include +using namespace std; +class Publication +{ + string title; + float price; + +public: + void getData() + { + cout << "\nEnter the title :" << endl; + cin>>title; + cout << "Enter price :" << endl; + cin >> price; + } + void putData() + { + cout << "\nTitle: " << title << "\nPrice: " << price; + } +}; +class Book : public Publication +{ +private: + int pages; + +public: + void getData() + { + Publication::getData(); + cout << "Enter Pages : "; + cin >> pages; + } + + void putData() + { + Publication::putData(); + cout << "\nPages : " << pages; + } +}; + +class Tape : public Publication +{ +private: + float minutes; + +public: + void getData() + { + Publication::getData(); + cout << "Enter Minutes :"; + cin >> minutes; + } + + void putData() + { + Publication::putData(); + cout << "\nMinutes : " << minutes; + } +}; + +int main() +{ + Book b; + Tape t; + b.getData(); + t.getData(); + + cout << "\a" << endl; + b.putData(); + cout << endl; + t.putData(); + cout << endl; + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/3.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/3.cpp new file mode 100644 index 0000000..ff3be63 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/3.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +void display(char = '*', int = 1); + +int main() { + int count = 5; + + cout << "No argument passed: "; + + display(); + + cout << "First argument passed: "; + + display('#'); + + cout << "Both arguments passed: "; + + display('$', count); + + return 0; +} + +void display(char c, int count) { + for(int i = 1; i <= count; ++i) + { + cout << c; + } + cout << endl; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/5.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/5.cpp new file mode 100644 index 0000000..686c70c --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 6 of set 2/5.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; + +class Class +{ +private: + int x, y; +public: + Class(int x1, int y1) { x = x1; y = y1; } + + // Copy constructor + Class(const Class &p1) {x = p1.x; y = p1.y; } + + int getX() { return x; } + int getY() { return y; } +}; + +int main() +{ + Class p1(10, 15); + Class p2 = p1; + + + cout << "p1.x = " << p1.getX() << ", p1.y = " << p1.getY(); + cout << "\np2.x = " << p2.getX() << ", p2.y = " << p2.getY(); + + return 0; +} diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q1.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q1.cpp new file mode 100644 index 0000000..15b66de --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q1.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; + +class Polygon { + public: + void set_value(int a, int b){ + height=a; + width=b; + } + virtual void calc_area() = 0; + protected: + int height; + int width; +}; + +class Rectangle: public Polygon { + public: + void calc_area(); +}; + +class Triangle: public Polygon { + public: + void calc_area(); +}; + + +void Rectangle::calc_area() { + cout << "Rectangle area: " << (height*width) << endl; +} + +void Triangle::calc_area() { + cout << "Triangle area: " << (height*width*0.5) << endl; +} + +int main() { + Polygon* sr; + Polygon* st; + Rectangle s1; + Triangle s2; + + sr=&s1; + st=&s2; + sr->set_value(5,2); + st->set_value(5,2); + sr->calc_area(); + st->calc_area(); + + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q2.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q2.cpp new file mode 100644 index 0000000..ae4bac8 --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q2.cpp @@ -0,0 +1,73 @@ +#include +using namespace std; +class shape +{ + protected: + float aoc,aor,aot,r,l,b,b1,b2,h; + public: + virtual void area()=0; + virtual void display()=0; +}; +class circle:public shape +{ + public: + void area() + { + cout<<"\nEnter radius of the circle:"; + cin>>r; + aoc=3.14159*r*r; + } + void display() + { + cout<<"\nArea of circle:"<>l>>b; + aor=l*b; + } + void display() + { + cout<<"\nArea of rectangle:"<>h; + cout<<"\nEnter length of each base(b1,b2) of the trapezoid:"; + cin>>b1>>b2; + aot=((b1+b2)/2)*h; + } + void display() + { + cout<<"\nArea of trapezoid:"<area(); + sc->display(); + sr=&r; + sr->area(); + sr->display(); + st=&t; + st->area(); + st->display(); + return 0; +} \ No newline at end of file diff --git a/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q3.cpp b/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q3.cpp new file mode 100644 index 0000000..ea8299d --- /dev/null +++ b/Computer Engineering - BE/Sem 2/UTA018/Assignment 8 of set 2/Q3.cpp @@ -0,0 +1,84 @@ +#include + +using namespace std; + +class Student +{ + +protected: + char name[20], depart[20]; + +public: + virtual void get_data() = 0; + virtual void show_data() = 0; +}; +class Engineering : public Student +{ +public: + void get_data() + { + cout << "Enter the information of Engineering student "; + cout << "\nEnter the name of Student: "; + cin >> name; + cout << "Enter Department: "; + cin >> depart; + } + void show_data() + { + cout << "The Information of Engineering student is "; + cout << "\nName : " << name; + cout << "\nDepartment: " << depart; + } +}; +class Medicine : public Student +{ +public: + void get_data() + { + cout << "Enter the information of Medicine student "; + cout << "\nEnter Name: "; + cin >> name; + cout << "Enter Department: "; + cin >> depart; + } + void show_data() + { + cout << "\nThe information of Medicine student is "; + cout << "\nName: " << name; + cout << "\n Department: " << depart; + } +}; +class Science : public Student +{ +public: + void get_data() + { + cout << "\nEnter information of Science Student: "; + cout << "\nEnter name: "; + cin >> name; + cout << "Enter Department: "; + cin >> depart; + } + void show_data() + { + cout << "The informaion of Science student is "; + cout << "\nName: " << name; + cout << "\nDepartment: " << depart; + } +}; +int main() +{ + Student *stu[3]; + stu[0] = new Engineering; + stu[1] = new Medicine; + stu[2] = new Science; + for (int i = 0; i < 3; i++) + { + stu[i]->get_data(); + } + for (int i = 0; i < 3; i++) + { + stu[i]->show_data(); + } + return 0; +} \ No newline at end of file