#include<iostream>
Saturday, May 31, 2025
Friends Pairing using Recursion in C++
Remove Duplicates using Recursion in C++
#include<iostream>
Friday, May 30, 2025
Book Library Management (University Question)
#include <iostream>
C. Create a C++ program that uses a function template to find the maximum value between two values of any data type.
#include <iostream>
using namespace std;
template<typename T>
T maxVal(T a, T b) {
return (a>b) ? a : b;
/*
if (a > b) {
return a;
} else {
return b;
}
*/
/*
OR
return (a > b) ? a : b is same as if
(a > b)
return a;
else
return b;
*/
}
int main() {
int val1, val2;
cout << "enter first value : ";
cin >> val1;
cout << "\nenter second value : ";
cin >> val2;
int findMax = maxVal(val1, val2);
cout << findMax << " is the max value " << endl;
return 0;
}
Thursday, May 29, 2025
A. Create a C++ program that demonstrates function overloading.
D. Create a C++ class template named Pair that represents a pair of values. (University Topic of OOPs)
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// D. Create a C++ class template named Pair that represents a pair of values.
template <typename T>
class Pair {
private:
T A1;
T A2;
public:
Pair(T val1,T val2) {
A1 = val1; // initialize first ehe private variable then the Public variable
A2 = val2;
}
// display
void display() {
cout << "value A: " << A1 << " \nvalue B: " << A2 << endl;
}
};
int main() {
int x, y;
cout << "enter first value : ";
cin >> x;
cout << "enter second value : ";
cin >> y;
Pair<int> class1(x, y);
class1.display();
return 0;
}
Merge Sort in C++ (university dsa topic)
#include <iostream>
Tuesday, May 27, 2025
Binary Search in C++ (University Topic)
Linear Search in C++ (University Topic)
#include <iostream>
using namespace std;
int linearSearch(int arr[], int size, int element) {
for(int i=0; i<size; i++) {
if(arr[i]==element) {
return i;
}
}
return -1;
}
int main() {
int arr[] = {10, 23,45,56,43,53};
int size = sizeof(arr)/sizeof(int);
int element = 56;
int searchResult = linearSearch(arr, size, element);
cout << "The element " << element << " is at index " << searchResult << endl;
return 0;
}
Tiling problem using Recursion in C++
#include <iostream>
Monday, May 26, 2025
X to the Power N(Code) using Recursion in C++
#include <iostream>
Last Occurence using Recursion in C++
#include <iostream>
Friday, May 23, 2025
First Occurence using Recursion in C++
#include <iostream>
Check if Array Sorted using Recursion in C++
Nth Fibonacci (Code) Using Recursion in C++
#include <iostream>
Sum of N natural numbers using Recursion in C++
#include <iostream>
Stack Overflow in C++
#include <iostream>
Thursday, May 22, 2025
Number in Decreasing order in Recursion in C++
#include <iostream>
Factorial in Recursion Memory in C++
#include <iostream>
What is recursion? in C++
Recursion:
A function that repeatedly calls itself.
CODE:
#include<iostream>
using namespace std;
// recursive function -> recursion..
void func() {
cout << "function call...work\n";
func(); // calls itself
}
int main() {
func();
return 0;
}
OUTPUT:-
function call..work
function call..work
function call..work
function call..work
function call..work
...
.
..
infinite times, until a base case is declared(Smallest problem, where solution is known)..
Sunday, May 18, 2025
Object-Oriented Programming: Creating a Student Class from Person Base Class (Assignment Question 3)
#include <iostream>
Bank Account Assigment Question in OOPs
#include <iostream>
Complex Number Class with Subtraction Operator Overloading in OOPs (Assignment Question 1)
#include <iostream>
using namespace std;
// Complex Number Substraction Code using Operator Overloading
class Complex {
private:
int real, img;
public:
Complex(int r, int i) {
real = r;
img = i;
}
void showNum() {
cout << real << " - " << img << "i\n";
}
// Operator Overloading
void operator-(Complex &c2) { // &c2 is value of reference..
int resReal = this->real - c2.real; // result of real
int resImg = this->img - c2.img; // result of image
Complex c3(resReal, resImg); // taking both objects of resReal , resImg.
c3.showNum(); // display the result
}
};
int main()
{
Complex c1(2, 4);
Complex c2(1, 2);
c1.showNum();
c2.showNum();
c1-c2;
return 0;
}
Friday, May 16, 2025
Predicting the output of friend function and class in OOPs - 02
#include <iostream>
Predicting the output of Friend class and function problem 1 in OOPs
#include <iostream>
Friend functions & class in OOPs
#include <iostream>
Sunday, May 11, 2025
Static keyword : Static Object in OOPs
}
output:
constructor..
code ending..
destructor..
Static Keyword - Static Variable in OOPs (02)
#include <iostream>
Static Keyword - Static Variables in OOPs
#include <iostream>
Pure Virtual Function in OOPs
#include <iostream>
Inorder Traversal (uni topic) in c++
#include <iostream> using namespace std; struct Node { int data; Node* left; Node* right; }; void inorder(Node* root) { // major mi...
-
The actual calculation behind:- 1. while(i<=n) { sum = sum + i; i++; } or 2. for(i = 1; i<=n; i++) { sum += i; // sum = sum + ...
-
FLOWCHART Start Input marks for 3 subjects (sub1, sub2, sub3) Calculate Total Marks (total = sub1 + sub2 + sub3) Calculate Average Marks ...
-
HackerRank - Resources for C Language Practice ~ Functions in C Language:- 1. Function to Find Maximum of Four Integers in C. - Picks the ...