download

No Comments

C++ program to implement Queue using Formula Based Representation

#include <iostream.h> #include <conio.h> class queue { private :   int *arr ; int front, rear ; int MAX ; public : queue( int maxsize = 10 ) ; void addq ( int item ) ; int delq( ) ; } ; queue :: queue( int maxsize ) { MAX = maxsize ; arr = […]

1 Comment

C++ program to implement Hash Table

#include <iostream.h> #include <stdlib.h> #include<constream.h> template<class E, class K> class HashTable { public: HashTable(int divisor = 11); ~HashTable() {delete [] ht; delete [] empty;} int Search(const K& k, E& e) const; HashTable<E,K>& Insert(const E& e); void Output();// output the hash table void del(E e); private: int hSearch(const K& k) const; int D; // hash function […]

5 Comments

C++ program to evaluate an expression entered in postfix form

#include <iostream.h> #include <stdlib.h> #include <math.h> #include <ctype.h> const int MAX = 50 ; class postfix { private :   int stack[MAX] ; int top, nn ; char *s ; public : postfix( ) ; void setexpr ( char *str ) ; void push ( int item ) ; int pop( ) ; void calculate( […]

10 Comments

C++ program to convert an Expression from Infix expression to Prefix form

#include <iostream.h> #include <string.h> #include <ctype.h> const int MAX = 50 ; class infix { private : char target[MAX], stack[MAX] ; char *s, *t ; int top, l ; public : infix( ) ; void setexpr ( char *str ) ; void push ( char c ) ; char pop( ) ; void convert( ) […]

11 Comments

C++ program to convert an Expression from Infix form to Postfix form

#include <iostream.h> #include <string.h> #include <ctype.h> const int MAX = 50 ; class infix { private : char target[MAX], stack[MAX] ; char *s, *t ; int top ; public : infix( ) ; void setexpr ( char *str ) ; void push ( char c ) ; char pop( ) ; void convert( ) ; […]

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]=’.’; […]

27 Comments

C++ program using class to generate mark sheet using multiple inheritance

Using multiple inheritances, prepare a Student Mark sheet, class marks for every student in three subjects. The inherited class generates mark sheet. #include<iostream.h> #include<stdio.h> #include<dos.h> class student { int roll; char name[25]; char add [25]; char *city; public: student() { cout<<"welcome in the student information system"<<endl; } void getdata() { cout<<"\n enter the student roll […]

29 Comments

C++ program to calculate the factorial of a number using recursion.

Write a program to calculate the factorial of a number using recursion. #include<iostream.h> #include<conio.h> void main() { int n,fact; int rec(int); clrscr(); cout<<"Enter the number:->"; cin>>n; fact=rec(n); cout<<endl<<"Factorial Result are:: "<<fact<<endl; getch(); } rec(int x) { int f; if(x==1) return(x); else { f=x*rec(x-1); return(f); } }

22 Comments

C++ program to multiply two numbers without using multiplication operator

Write a c++ program to multiply two numbers without using multiplication operator. #include<iostream.h> #include<conio.h> void main () { int a,b,i,temp=0; clrscr(); cout<<"Enter Two numbers for multiplication"; cin>>a>>b; for(i=1;i<=b;i++) { temp=temp+a; } cout<<endl<<"Result are:: "<<temp; getch(); }

9 Comments

C program for Round Robin

C program for Round Robin   #include<stdio.h> #include<conio.h> #include<iostream.h> int t,n,s,bt[10],ct[10],ta[10],w[10],lat[10],wav,taav; int allover() { for(int i=0;i<n;i++) if(ct[i]>0) return 0; return 1; } void select(int p) { w[p]+=t-lat[p]; if(ct[p]>=s) { ct[p]-=s; t+=s; } else { t+=ct[p]; ct[p]=0; } if(ct[p]==0) ta[p]=t; lat[p]=t; } void main() { int p=0;t=0;taav=0;wav=0; clrscr(); printf("Enter the number of process : "); scanf("%d",&n); […]