Recursion Function Method in Data structure and Algorithm in Java
byHassan Ali
-
0
import java.util.*;
class Recursion {
public static void main(String [] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the Number to Find Factorial");
int n = input.nextInt();
System.out.println("Factorial of Number is =" + fact(n));
}
static int fact(int n){
if(n==1){
return 1;
}else{
return n*fact(n-1);
}
}
}
#include<iostream>
#include<conio.h>
using namespace std;
void pakistan(void);
void england(void);
int main()
{
cout<<"I am in Main"<<endl;
pakistan();
cout<<"Back in Main";
getch();
}
void pakistan(void)
{
cout<<"I love Pakistan"<<endl;
england();
cout<<"I am back in Pakistan"<<endl;
}
void england(void)
{
cout<<"I am in England Function"<<endl;
cout<<"Going to England"<<"\n";
cout<<"I am Back toward Main"<<endl;
}
#include<iostream>
#include<conio.h>
using namespace std;
void pakistan(void);
void england(void);
using namespace std;
int main()
{
system ("color 3F");
cout<<"Welcome"<<"\n"
pakistan();
cout<<"Welcome Back to return"<<"\n";
england();
getch();
}
void pakistan(void)
{
cout<<<"Hello Hassan"<<endl;
}
void england(void)
{
cout<<"Welcome to England ";
}
Post a Comment