Programs

C Program to draw star pattern

#include <stdio.h> int main() { int i, j, k; for(i=1;i<=5;i++) { for(j=1;j<=6-i;j++) { printf("*"); } for(k=1;k<i;k++) { printf(" "); } for(j=1;j<=6-i;j++) { printf("*"); } printf("\n"); } for(i=2;i<=5;i++) { for(j=1;j<=i;j++) { printf("*"); } for(k=1;k<=5-i;k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } getchar(); return 0; }

Advertisements
How to, Uncategorized

How to run assembly language programs in TASM

Turbo Assembler (TASM) is a computer assembler (software for program development) developed by Borland which runs on and produces code for 16- or 32-bit x86 MS-DOS or Microsoft Windows. It can be used with Borland's high-level language compilers, such as Turbo Pascal, Turbo Basic, Turbo C and Turbo C++. Download TASM Steps for executing an… Continue reading How to run assembly language programs in TASM

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