Life Hacks


      

CPP and C programs

Write a program of the Quick Sort.

#include<iostream.h> #include<conio.h> int a[10], l, u, i, j; /* local variable */ void quick(int *, int, int); void main( ) /* main start */ { clrscr( ); cout << “ Enter 10 elements : ”; for(i = 0; i < 10; i ++) { cin >> a[i]; } /* End of for loop */ l […]

Write a program of the Heap Sort.

#include<iostream.h> #include<conio.h> int arr[20], n; class heap { private: int loc, num, par; /* local variable */ public: void del_root(int); void create_heap( ); void display( ); void heap_sort( ); void insert(int, int); }; void heap :: insert(int num, int loc) { int par; /* local variable */ while(loc > 0) { par = (loc – […]

Write a program of the Binary Search.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[20], n, c, lb, ub, item, mid, loc; /* local variable */ cout << " \n Enter the number of elements in an array is: " << " \n "; cin>>n; // entering no. of elements for the array. cout << " […]

Write a program of the Insertion Sort.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[50], n, i, ptr, temp; /* local variable */ cout << " Enter the number of elements in an array is : ”; cin >> n; // Enter the no. of elements wants to be sorted. a[0] = 0; cout << " […]

Write a program of the Selection Sort.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int array[10], n, i, j, temp; /* local variable */ cout << " Enter the number of elements in an array is : ”; cin >> n; // inserting no. of elements in the array. cout << “ Enter “ << “ “ […]

Write a program of the Bubble Sort.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int num[56], n, k, c, ptr, temp; /* local variable */ cout<<"enter the number of elements in an array is : ”; cin>>n; // inserting no. of elements in the array. cout<<"enter the value of elements of array is : "; for(c = […]

Write a program of the deletion in an array.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[20], j, n, k, b, c, item; /* local variable */ cout << " \n Enter the number of elements in an array is : " << " \n "; cin >> n; cout << " \n Enter the value of elements […]

Write a program of the insertion in an array.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[20], j, n, k, b, c; /* local variable */ cout << " \n Enter the number of elements in an array is: " << " \n "; cin >> n; cout << " \n Enter the value of elements of array […]

PROGRAM FOR THE HEAP SORT

#include<iostream.h> #include<conio.h> int arr[20], n; class heap { private: int loc, num, par; public: void del_root(int); void create_heap(); void display(); void heap_sort(); void insert(int, int); }; void heap :: insert(int num, int loc) { int par; while(loc > 0) { par = (loc – 1) / 2; if(num <= arr[par]) { arr[loc] = num; return; […]

RSA cryptography program

#include<iostream.h>#include<conio.h>#include<math.h>void main(){clrscr();double p,q,n,fn,e,d,pt,ct;cin>>p>>q;n=p*q;fn=(p-1)*(q-1);cin>>e;for(d=0;d<100;d++){if( (fmod((d*e),fn))==1 ){break;}}cin>>pt;ct=fmod(pow(pt,e),n);cout<<ct<<endl;pt=fmod(pow(ct,d),n);cout<<pt;getch();}

Previous Posts Next posts