Posts

Hill Cipher program in C++ language

#include<iostream> #include<math.h>   using namespace std;   float encrypt[2][1], decrypt[3][1], a[2][2], b[2][2], mes[2][1], c[2][2];   void encryption();    //encrypts the message void decryption();    //decrypts the message void getKeyMessage();    //gets key and message from user void inverse();        //finds inverse of key matrix   int main() {     getKeyMessage();     encryption();     decryption(); }   void encryption() {     int i, j, k;          for(i = 0; i < 2; i++)         for(j = 0; j < 1; j++)             for(k = 0; k < 2; k++)                 encrypt[i][j] = encrypt[i][j] + a[i][k] * mes[k][j];          cout<<"\nEncrypted string is: ";     for(i = 0; i < 2; i++)     ...

Open any website that you want for any number of times program in C++ language

#include<cstdlib> #include<iostream> #include<conio.h> using namespace std; int main() { int i; for(i=0;i<10;i++) { system("start https://www.youtube.com/watch?v=6PqA9b86ki8"); } }

Friend Function in C++ language

#include<iostream> using namespace std; class demo { int x; public: void init(int a) { x=a; } friend void show(demo); }; void show(demo d) { cout<<"number is:"; cout<<d.x; } int main() { demo obj; obj.init(10); show(obj); return 0; }

Eligible for vote and find square program in C++ language

#include<iostream> using namespace std; int sqr(int r); int main() { int age,n; cout<<"Enter your age:\n"; cin>>age; if(age<18) { cout<<"You are not elgible for vote\n"; }else { cout<<"You are elgible for vote\n"; } cout<<"Lets find square\n"; cout<<"Enter your value:\n"; cin>>n; int ans =sqr(n); cout<<"sqr of "<<n<<" is:\n"<<ans; return 0; } int sqr(int r) { return r*r; }

Two objects same or not program in C++ language

#include<iostream> using namespace std; class demo { int a,b; public: void get() { cout<<"enter a number:"; cin>>a; cout<<"enter another number:"; cin>>b; } int check(demo d1,demo d2) { if (d1.a==d2.a && d1.b==d2.b) { return 0; } else { return 1; } } }; int main() { int flag; demo a1,a2; a1.get(); a2.get(); flag=a1.check(a1,a2); if (flag==1)     {     cout<<"number is not same"; } else { cout<<"number is same"; } return 0; }

Destructor in C++ language

#include<iostream> using namespace std; class demo { public: demo() { cout<<"constructor is called"<<endl; } ~demo() { cout<<"destructor is called"<<endl; } }; void fun() { demo d; } int main() { cout<<"before.........."<<endl; fun(); cout<<"after..........."; return 0; }

Copy Constructor in C++ language

#include<iostream> using namespace std; class rect  { int  l,b; public: rect(int x,int y) { l=x,b=y; } rect(rect &x) { l=x.l; b=x.b; } void show() { cout<<l<<"\n"<<b<<"\n"; } }; int main() { rect r1(10,20),r2(r1); r1.show(); r2.show(); return 0; }
❤ HOPE YOU LIKE IT ❤