82. Write a program to solve the problem of tower of Hanoi with given disk?

#include<iostream.h> #include<conio.h> void hanoi(int disk,char s,char t,char d) {                 if(disk==1)                                 {                                 cout<<"Move Disk "<<disk<<" From "<<s<<" To "<<d<<endl;                                 return;                                 }                 hanoi(disk-1,s,d,t);          //Recursive Function Call                 cout<<"Move Disk "<<disk<<" From "<<s<<" To "<<d<<endl;                 hanoi(disk-1,t,s,d);          //Recursive function call } void main() {                 char s='A',t='B',d='C';                 int disk;                 … Continue reading 82. Write a program to solve the problem of tower of Hanoi with given disk?

Advertisements

81. Write a program to find the sum between two number using recursive function?

#include<iostream.h> #include<conio.h> int x; int add(int i) {                 if(i==x-1)                                 {                                 return 0;                                 }                 else                                 {                                 return(i+add(i-1));                                 } } void main() {                 int a,b,c;                 clrscr();                 cout<<"Enter Two Number : \n";                 cin>>a>>b;                 x=a;                 c=add(b);                 cout<<"The Sum Between "<<a<<" and "<<b<<" = "<<c<<endl; … Continue reading 81. Write a program to find the sum between two number using recursive function?

80. Write a program to add two numbers using recursive function?

#include<iostream.h> #include<conio.h> int x; int add(int i) {                 if(i==0)                                 {                                 return x;                                 }                 else                                 {                                 return(1+add(i-1));                                 } } void main() {                 int a,b,c;                 clrscr();                 cout<<"Enter Two Number : \n";                 cin>>a>>b;                 x=a;                 c=add(b);                 cout<<"The Addition of "<<a<<" and "<<b<<" = "<<c<<endl; … Continue reading 80. Write a program to add two numbers using recursive function?

79. Write a program to perform factorial of given number?

#include<iostream.h> #include<conio.h> long factorial(int i); void main() {                 int n,result;                 clrscr();                 cout<<"Enter A Number For Factorial : ";                 cin>>n;                 result=factorial(n);                 cout<<"The Factorial of "<<n<<" = "<<result<<endl;                 getch(); } long factorial(int i) {                 if(i==0)                                 {                                 return 1;                                 }                 else                                 {                                 return(i*factorial(i-1));                                 … Continue reading 79. Write a program to perform factorial of given number?

78. Write a program to perform addition using function overloading technique?

  A. #include<iostream.h> #include<conio.h> void add(int a,int b); float add(double d,int i); void add(int p,int q,int r); void main() {                 float f;                 clrscr();                 add(10,5,3);                 f=add(10.5,25);                 add(30,5);                 cout<<"F : "<<f<<endl;                 getch(); } void add(int a,int b) {                 cout<<"A+B = "<<a+b<<endl; } float add(double d,int i) {                 return … Continue reading 78. Write a program to perform addition using function overloading technique?

77. Write a program to print the output of following program?

#include<iostream.h> #include<conio.h> void main() {                 int x=5,y=5,p,q;                 clrscr();                 p=++x + x++ + ++x;                 q=y++ + ++y + ++y + y++;                 cout<<"P : "<<p<<endl;                 cout<<"Q : "<<q<<endl;                 cout<<"X : "<<x<<endl;                 cout<<"Y : "<<y<<endl;                 getch(); }

76. Write a program to demonstrate inline function and macro to perform multiplication?

#include<iostream.h> #include<conio.h> #define MUL(a) a*a       //Macro Definition inline int mul(int a)          //Inline Function Definition {                 return(a*a); } void main() {                 int x=5,y=5,p,q;                 clrscr();                 p=mul(++x);       //Inline Function Call                 q=MUL(++y);     //Macro Call                 cout<<"The Multiplication From Inline Function : "<<p<<endl;                 cout<<"The Multiplication From Macro : "<<q<<endl;                 cout<<"X : "<<x<<endl;                 … Continue reading 76. Write a program to demonstrate inline function and macro to perform multiplication?

Tower of Hanoi: –

Tower of Hanoi: - The problem of tower of Hanoi is to how move the disk from one pillar to another pillar. There are some rules to solve the tower of Hanoi. Small disk will be placed on large disk (The disk will be inserted into decreasing order on pillar). At a time our only … Continue reading Tower of Hanoi: –

Recursion: –

Recursion: - It is a technique in which a function calls to itself based upon verifying the condition, then such type of function is called as recursive function. There are some rules to be followed – To come out from recursive function be have two statement either exit() or return. Both the statement will be … Continue reading Recursion: –

Function overloading: –

Function overloading: - It is a type of polymorphism. It is possible in the case with without class or inline one class. If more than one function have some name to perform difference task then the term is called as function overloading. Following are some characteristic of function overloading – The return type may be … Continue reading Function overloading: –