Source Codes

2 Comments

C++ rogram to implement merge sort

#include <iostream.h> const int MAX = 5 ; class array { private : int *a ; int size ; int count ; public : array( ) ; array ( int sz ) ; void add ( int num ) ; void display( ) ; void merge_sort(int low,int high); void merge(int low,int mid,int high); ~array( ) […]

7 Comments

C++ program to implement Insertion sort using class

#include <iostream.h> const int MAX = 10 ; class array { private : int arr[MAX] ; int count ; public : array( ) ; void add ( int item ) ; void sort( ) ; void display( ) ; } ; array :: array( ) { count = 0 ; for ( int i = […]

6 Comments

C program to Implement Morse code to text conversion and vice-versa.

C program to Implement Morse code to text conversion and vice-versa. #include<stdio.h> #include<conio.h> #include<string.h> #include<process.h>   void main() { char str[25],str1[100]; clrscr(); fflush(stdin); printf("enter the String"); gets(str);   int j=0; for(int i=0;i<=strlen(str);++) { switch(toupper(str[i])) { case ‘A’: str1[j++]=’.’; str1[j]=’.’; break;   case ‘b’: str1[j++]=’.’; str1[j++]=’.’; str1[j++]=’.’; str1[j]=’.’; break;   case ‘c’: str1[j++]=’.’; str1[j++]=’.’; str1[j++]=’.’; str1[j]=’.’; […]

3 Comments

C++ class program to perform rational number arithmetic

Write a program to perform rational number arithmetic. #include<stdio.h> #include<iostream.h> #include<conio.h> class rational { int numer; int denom; public: void getdata() { cout<<"\n enter the numerator part of the rational no."; cin>>numer; cout<<"\n enter the denominator part of the rational no."; cin>>denom; } void operator+(rational); void operator-(rational); void operator *(rational); void operator /(rational); }; void […]

17 Comments

C progrma for First Come First Serve Algorithm

C progrma for First Come First Serve Algorithm #include<stdio.h> #include<math.h> #include<conio.h> void main() { clrscr(); int p[20],b[20],w[20],t[20],i,v,n,at; int wt=0; float tw,tr; printf("Enter the number of process : "); scanf("%d",&n); printf("enter CPU burst time : "); for(i=1;i<=n;i++) { scanf("%d",&b[i]); t[1]=b[1]; w[1]=0; at=t[1]; wt=w[1]; for(i=2;i<=n;i++) { t[i]=b[i]+t[i-1]; at=at+t[i]; w[i]=t[i-1]; wt=wt+w[i]; } } printf("process \t burst_time \t wait_time […]

4 Comments

C++ program to copy one file to anothere file

AIM A program to copy one file to another file and convert the lower case characters to upper case characters. ALGORITHM 1) Start the process 2) Create the input file and out put file. 3) Get the input file name to fname1. 4) Get the output file name to fname2. 5) Open the infile(fanme1) 6) […]

52 Comments

C++ program to illustrate a Single Inheritance

SINGLE INHERITANCE AIM: A program to illustrate a single inheritance. We have a base class B and a derived class D. The class B contains one private data member, one public data member and three public member functions. The class D contains one private data member and two public member functions ALGORITHAM: • Start the […]

1 Comment

C++ program for overloading the unary operator ++.

ALGORITHAM: • Start the process • Invoke the class counter • Crate two objects c1 and c2 • Assign values to c1 an c2 o Call c1.get_count() o Call c2.get_count() • Increment the values o C1++ o C2++ o ++c2 • Print c1 and c2 • Stop the process PROGRAM #include<iostream.h> #include<conio.h> class counter { […]

No Comments

c++ Program to illustrate the use of difference operators using friend function

AIM: A program to illustrate the use of difference operators to access the class member using friend function ALGORITHM: 1) Start the process 2) Invoke the classes 3) Call the set_xy() first a) Assign the value of x and y b) Print the value of x and y 4) Call the sum() for second(friend) a) […]

No Comments

C++ program for implementation of class

AIM: A program to solve a quadratic equation, using OOP techniques. ALGORITHM: 1) Start the process 2) Invoke the classes 3) Get the input for a,b,c; 4) Call the function getinfo() and display() 5) Check if a=0 a) True : compute c/b; i) Print the value of a/c; b) False: compute b*b-4*a*c; i) If ( […]