Programs, Uncategorized

Inheritance in C++ | program to build master table of data

#include<iostream> #include<cstring> using namespace std; class base1 { char dob[10],bg[3]; public: char name[20]; void get1(); void disp1(); }; class base2 { float ht,wt; public: void get2(); void disp2(); }; class base3 { int policyno; char address[20]; public: void get3(); void disp3(); }; class derived:public base1,public base2,public base3 { int tno,dln; public: int present; derived() {… Continue reading Inheritance in C++ | program to build master table of data

Programs, Uncategorized

Simple template function program in C++

#include<iostream> using namespace std; const int r=2,c=2; template <class T> class matrix { T m[r][c]; public: void getval() { for(int i=0;i<r;i++) { for(int j=0;j<c;j++) { cout<<"\nm"<<"["<<i<<"]["<<j<<"]"; cin>>m[i][j]; } } } void display() { for(int i=0;i<r;i++) { for(int j=0;j<c;j++) { cout<<m[i][j]<<"\t"; } cout<<"\n"; } } void operator+(matrix obj) { T p[r][c]; for(int i=0;i<r;i++) { for(int j=0;j<c;j++)… Continue reading Simple template function program in C++

Programs, Uncategorized

C++ program on simple exception handling (divide by zero)

#include<iostream> using namespace std; class excdemo { public: double x,y; void getval() { cout<<"\nEnter the val of x and y="; cin>>x>>y; } void divide() { try{ if(y==0) { throw y; } else{ cout<<"\ndivision of entered no="<<x/y; } } catch(double) { cout<<"\nInside the catch"; throw; } } }; int main() { try{ excdemo e; e.getval(); e.divide();… Continue reading C++ program on simple exception handling (divide by zero)

Programs, Uncategorized

C++ Program to find Area of rectangle and the area of triangle using virtual function

#include<iostream> using namespace std; class complex { int r,i; public: complex() { r=0,i=0; } complex(int a,int b) { r=a,i=b; } void get(); void display(); friend complex operator+(complex c1,complex c2); friend complex operator-(complex c1,complex c2); complex operator*(complex c1); complex operator/(complex c1); }; void complex::get() { cout<<"\nEnter real no.:\n"; cin>>r; cout<<"\nEnter ima.part:\n"; cin>>i; } void complex::display() {… Continue reading C++ Program to find Area of rectangle and the area of triangle using virtual function

Programs, Uncategorized

c++ program to Add, Subtract, Multiply, divide two complex numbers

#include<iostream> using namespace std; class complex { int r,i; public: complex() { r=0,i=0; } complex(int a,int b) { r=a,i=b; } void get(); void display(); friend complex operator+(complex c1,complex c2); friend complex operator-(complex c1,complex c2); complex operator*(complex c1); complex operator/(complex c1); }; void complex::get() { cout<<"\nEnter real no.:\n"; cin>>r; cout<<"\nEnter ima.part:\n"; cin>>i; } void complex::display() {… Continue reading c++ program to Add, Subtract, Multiply, divide two complex numbers

Programs, Uncategorized

c++ Bookshop program

#include<iostream> #include<cstring> using namespace std; class book { char *title,*author,*publisher; int *stock,*price; static int trans; public: book() /*constructor*/ { trans++; title=new char[20]; author=new char[20]; publisher=new char[20]; stock = new int; price = new int; } void Add(); int Search(char bt[20],char baut[20]); void update(); void buy(); static void transactions(); void show(); }; int book::trans; //static member… Continue reading c++ Bookshop program

Programs, Uncategorized

c++ program for create wheather report

#include<iostream> #include<iomanip> using namespace std; class wheather { public: int ltemp,htemp,rain,snow; wheather() { ltemp=-100; htemp=100; rain=200; snow=200; } void getdata() { cout<<"\nEnter low temp"; cin>>ltemp; cout<<"\nEnter high temp"; cin>>htemp; cout<<"\nEnter the amount of rain"; cin>>rain; cout<<"\nEntr the amount of the snow"; cin>>snow; } void display() { cout<<"\nlow temp:"<<ltemp<<"\nhigh temp:"<<htemp<<"\nrain:"<<rain<<"\nsnow"<<snow; } }; int main() { wheather… Continue reading c++ program for create wheather report

Programs, Uncategorized

assembly program to perform operations on given string compare, concat [TASM]

main.asm create this file contains menu for program .model small .data extrn str4,str5,maxlen1,maxlen2,maxlen3 .code public concat public compare concat proc far CLD LEA SI,maxlen1 LEA DI,maxlen3 inc SI mov CL,[si] mov ch,00h inc si REP MOVSB LEA si,maxlen2 inc SI mov cl,[si] mov ch,00H inc si REP MOVSB mov [di],'$' mov dx,offset maxlen3 mov ah,09H… Continue reading assembly program to perform operations on given string compare, concat [TASM]

Programs, Uncategorized

assembly program for file handling using inbuilt structures REGS and SREGS [Turbo c++]

#include<dos.h> #include<stdio.h> #include<conio.h> int create_dir( char far *file) { union REGS regs; struct SREGS sregs; int ret; regs.h.ah=0x39; sregs.ds=FP_SEG(file); regs.x.dx=FP_OFF(file); ret=intdosx(&regs,&regs,&sregs); return(regs.x.cflag? ret:0); } int create_file( char far *file) { union REGS regs; struct SREGS sregs; int ret; regs.h.ah=0x3c; sregs.ds=FP_SEG(file); regs.x.dx=FP_OFF(file); ret=intdosx(&regs,&regs,&sregs); return(regs.x.cflag? ret:0); } int delete_file( char far *file) { union REGS regs; struct… Continue reading assembly program for file handling using inbuilt structures REGS and SREGS [Turbo c++]

Programs, Uncategorized

Assembly Program to conversion of BCD to HEX and HEX to BCD [TASM]

dis macro str mov dx,offset str mov ah,09h int 21h endm .model small .data menu1 db  0AH,0DH, "--------Menu-$" menu2 db 0AH,0DH, "    1.Hex to BCD      2.BCD to Hex$" str1 db 0AH,0DH,"Enter Your Choice$" str2 db 0AH,0DH,"Enter hex no$" str3 db 0AH,0DH,"Enter BCD no$" str4 db 0AH,0DH," BCD form is$" str5 db 0AH,0DH,"hex form is$" INPUTNO… Continue reading Assembly Program to conversion of BCD to HEX and HEX to BCD [TASM]