c++

Program to built matrix with the use of new and delete operator.

#include #include main() { int (*pa)[4]=new int [3][4]; int *pn=new int,i,j; int *pm=new int; clrscr(); cout<>*pn; cout<>*pm; cout<<"n Enter the elements : "; for(i=0;i<=*pn-1;i++) { for(j=0;j>pa[i][j]; } } cout<<"nnn Matrix Form : n"; for(i=0;i<=*pn-1;i++) { for(j=0;j<=*pm-1;j++) { cout<<pa[i][j]<<" "; } cout<<"n"; } delete[] pa; getch(); }

Program to show fibonacci series by overloading unary operator.

#include #include class fibn { private: int f0,f1,fib; public: fibn(); void display(); int operator++(); }; fibn::fibn() { f0=0; f1=1; fib=(f0+f1); } void fibn::display() { cout<<"n "<<fib; } int fibn::operator++() { f0=f1; f1=fib; fib=(f0+f1); } main() { class fibn obj; int i,n; clrscr(); cout<>n; for(i=0;i<=n;i++) { obj.display(); obj.operator++(); } getch(); }

Program to enter the n number of records of the students into the file with the concept of structure concept

#include #include #include int const max =100; struct student_info { char name[20]; long int rn; char sex; int age; }; void main() { student_info obj1[30]; int n,i; fstream infile; clrscr(); char fname[20]; cout<>fname; infile.open(fname,ios::in||ios::out); cout<>n; cout<<"nenter the following information n"; for(i=0;i<=n-1;++i) { cout<>obj1[i].name; cout<>obj1[i].rn; cout<>obj1[i].sex; cout<>obj1[i].age; } cout<<" nstoring onto the file ……………………n"; infile.open(fname,ios::out); for(i=0;i<=n-1;i++) […]

Program to create a text file by using object belonging to fstream for reading/writing mode.

#include #include #include #include #include main() { ofstream vasu; char fn[15],ch; clrscr(); cout<>fn; vasu.open(fn); if(vasu.fail()) { cout<<"n File Can't Be Opened … Try Again….."; getch(); exit(1); } else { vasu<<"n Today we are meeting for ugca1909"; vasu<<"n All class members are participating in it."; vasu<<"n I am sharing my screen during this class."; } vasu.close(); […]