Friday, September 11, 2009

C++ Programs

Employee details and to output the data
Fibonacci Numbers Sum Of Digits
Constructor - Default Constructor
Parameterized Constructor
Constructor Overloading
Copy Constructor
Function Overloading - Program
Outside Declaration Of The Member Function Inside Declaration Of The Member Function Overloading Unary Operator
Overloading Unary Operator Using + Operator
Merge Sort Program - Algorithm File Mode Program
File Concept Program
Exception Handling Program
Function Templates Program
Virtual Function Program
Friend Function Program Multilevel Inheritance
Multiple Inheritance Program Single Inheritance Program Static Member Function
Creation Of Class And Function
Static Class Member
Destructor Program
Constructor Program

Book Entity

Write a program using structure to define the elements of a book entity and to display the same.

/* Code for defining a structure and to display using structure */


#include"iostream.h"
#include"string.h"
struct book

{
int bookno;
char bookname[30];
char author[25];
float price;
};
void main()
{
book mybook;
mybook.bookno = 100;
strcpy(mybook.bookname,"Introduction to C++");
strcpy(mybook.author,"Surya");
mybook.price = 150.00;
cout << "The book number is " << mybook.bookno;
cout << "The book name is " << mybook.bookname;
cout << "The author of the book is " << mybook.author;
cout << "The price of the book is " << mybook.price;
}