C Programs

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 […]

6 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( ) ; […]

No Comments

Program to implement Linear Search algorithm

#include<iostream.h> #include<constream.h> void read(int a[10],int n) { cout<<"reading\n"; for(int i=0;i<n;i++) cin>>a[i]; } void display(int a[10],int n) { for(int i=0;i<n;i++) cout<<a[i]<<"\t"; } void linearsearch ( int a[10],int n ) { int k,flag=0; read(a,n); display(a,n); cout<<"\nenter an element to be search\n"; cin>>k; for(int i=0;i<n;i++) { if(a[i]==k) flag=1; break; } if(flag==1) cout << "\nsearching is successful,element is found […]

1 Comment

What is the use of extern in c/c++?

The extern keyword is used to tell the compiler that a data object is declared in a different *.cpp or *.c file. So there wont be any new memory is allocated for these variables. Check the below example and understand the working. //file1.cpp #include <iostream.h>   int x; extern void func2();   void func1(void) { […]

28 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 […]

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 […]

24 Comments

C program for Pass-1 Assembler

C program for Pass-1 Assembler #include<iostream.h> #include<conio.h> #include<stdio.h> #include<stdlib.h> #include<string.h> int symi=0,lc=0,len=1,dc=0,start=0; struct pgm { char line[80]; } s[100]; struct symtab { char name[10]; int add; } sym[100]; void show(char* a,char* b,char* c) { printf("%8s %5s %6s \n",a,b,c); } void check(char s[]) { if(!strcmpi(s,"START")) { start=1; show("","START","1"); return; } if(!strcmpi(s,"END")) { show("","END","1"); return; } if(!strcmpi(s,"EQU")) […]


Electrofriends
Submit Your

Research Papers

Click Here to Submit

Electrofriends
Submit Your

Projects

Click Here to Submit

Free email signup

Get latest projects, articles in your mail box, subscribe to electrifriends

Email:
Recent Questions
    Technical Papers