A

@abhaumik

Inheritence

C++
1 year ago
#include <iostream> using namespace std; class Base { private: int baseval1; public: Base(int val) : baseval1(val){}

Inheritence of classes

C++
2 years ago
#include <iostream> using namespace std; class vehicle { public: string noofvehicle; string make; string model;

creation of class couple

C++
2 years ago
#include <iostream> using namespace std; class couple { private: int first; int second;

string addition and concatenation

C++
2 years ago
#include <iostream> using namespace std; int main() { string str1 = "Ankita"; string str2 = "Bhaumik"; string str3 = str1 + " " + str2; cout<<str3<<endl; str1 += " ";

giving space after every character

C++
2 years ago
#include <iostream> using namespace std; int main() { string name; cin>>name; name[0] = 'A'; int length_of_name = name.size();

sum of each row in 2d array

C++
2 years ago
#include <iostream> using namespace std; int main() { int arr[4][5] = { {3,5,6}, {7,8,3}, {10,2,7}, {9,7,3}, };

Matrix multiplication

C++
2 years ago
#include <iostream> using namespace std; int main() { int A[3][4] = { {4,1,2,6}, {15,3,9,7}, {20,11,8,10}, };

2D arrays

C++
2 years ago
#include <iostream> using namespace std; int main() { // int student_marks[6][5] = { // {1,2,3,4,5}, // {6,7,8,9,10}, // {11,12,13,14,15} // };

Insertion and deletion in the array

C++
2 years ago
#include <iostream> using namespace std; const int cap = 10; int ar[cap]; int siz=0; int i = 0; bool insert_at_end(int a) {

print the odd and even elements in two diff arrays

C++
2 years ago
#include <iostream> using namespace std; int main() { int n; cin>>n; int arr[n]; for(int i = 0; i < n; i++)

given a sorted array , find the median

C++
2 years ago
#include <iostream> using namespace std; int main() { int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) { cin>>arr[i];

reverse the array

C++
2 years ago
#include <iostream> using namespace std; int main() { int n,temp=0; cin>>n; int arr[n]; for(int i=0;i<n;i++) { cin>>arr[i];

Find the first min and 2nd min of an array

C++
2 years ago
#include <bits/stdc++.h> using namespace std; int main() { int size; cin>>size; int * const arr = new int[size]; for(int i=0;i<size;i++) {

Check if array is sorted

C++
2 years ago
#include <iostream> using namespace std; int main() { int count=1; for(int i=0;i<n-1;i++) { if(arr[i]<=arr[i+1]) { }

diamond pattern

C++
2 years ago
#include <iostream> using namespace std; int main() { int row; cin>>row; for(int i=1;i<=row;i++) {

print the pattern

C++
2 years ago
#include <iostream> using namespace std; int main() { int row; cin>>row; for(int i=1;i<=row;i++) { for(int j=1;j<=row;j++)

print the pattern

C++
2 years ago
#include <iostream> using namespace std; int main() { int rows,cols; cin>>rows>>cols; for(int i=1;i<=rows;i++) {

Perfect number ( whose factor sums to the number itself)

C++
2 years ago
#include <iostream> using namespace std; int main() { int num =0,sum=0; cin>>num; for(int number=1;number<=num;number++) { sum=0;

Hcf of two numbers

C++
2 years ago
#include <iostream> using namespace std; int main() { int num1, num2, smaller_num=0, hcf=1; cin>>num1>>num2; if(num1<num2) { smaller_num = num1;

number is prime or not

C++
2 years ago
#include <iostream> using namespace std; int main() { int num,i,count=0; cin>>num; if(num==0 || num==1) { cout<<"not prime"<<endl; }