C C++ program to find power of number using recursion

C C++ program to find power of number using recursion

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

C program to find power of number using recursion

#include<stdio.h>
int power(int,int);
int main()
{
    int num,pow,c=1,res=1;
    printf("Enter number: ");
    scanf("%d",&num);
    printf("Enter power : ");
    scanf("%d",&pow);
    printf("Result = %d",power(num,pow));
    return 0;
}
int power(int num, int pow)
{
    if(pow==0)
        return 1;
    else
        return num*power(num,pow-1);
}

C++ program to find power of number using recursion

#include<iostream>
using namespace std;
int power(int,int);
int main()
{
    int num,pow,c=1,res=1;
    cout<<"Enter number: ";
    cin>>num;
    cout<<"Enter power : ";
    cin>>pow;
    cout<<"Result = "<<power(num,pow);
    return 0;
}
int power(int num, int pow)
{
    if(pow==0)
        return 1;
    else
        return num*power(num,pow-1);
}

Output of C C++ program to find power of number using recursion

C C++ program to find power of number using recursion

Similar recursion based programs in C C++

  1. Series of natural numbers
  2. Table of number
  3. Factorial of number
  4. Fibonacci series
Share it to:

C C++ program generate factorial of number using recursion

C C++ program generate factorial of number using recursion

C Language में Pointer क्या प्रयोग करते हुए किसी Function को कैसे point किया जा सकता है जानने के लिए देखें—Pointer to function

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

C Language में उपलब्ध विभिन्न प्रकार के Pointers और उनके उपयोग को जानने के लिए देखें—Types of Pointer in C

C program generate factorial of number using recursion

#include<stdio.h>
int fact (int);
int main()
{
    int num,c=1,res=1;
    printf("Enter a number: ");
    scanf("%d",&num);
    printf("Factorial = %d",fact(num));
    return 0;
}
int fact(int x)
{
    if(x==0)
        return 1;
    else
        return x*fact(x-1);
    return 0;
}

C++ program generate factorial of number using recursion

#include<iostream>
using namespace std;
int fact (int);
int main()
{
    int num,c=1,res=1;
    cout<<"Enter a number: ";
    cin>>num;
    cout<<"Factorial = "<<fact(num);
    return 0;
}
int fact(int x)
{
    if(x==0)
        return 1;
    else
        return x*fact(x-1);
    return 0;
}

Output of C C++ program generate factorial of number using recursion

C C++ program generate factorial of number using recursion

Important recursion programs in C C++

  1. Series of natural numbers
  2. Table of number
  3. Power of number
  4. Fibonacci series
Share it to:

C C++ program to generate table of number using recursion

C C++ program to generate table of number using recursion

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C program to generate table of number using recursion

#include<stdio.h>
void table(int,int,int);
int main()
{
    int num,c=1,res;
    printf("Enter a number: ");
    scanf("%d",&num);
    table(num,c,res);
    return 0;
}
void table(int num, int c, int res)
{
    if(c<=10)
    {
        res=num*c;
        printf("%d\n",res);
        table(num,c+1,res);
    }
}

C++ program to generate table of number using recursion

#include<iostream>
using namespace std;
void table(int,int,int);
int main()
{
    int num,c=1,res;
    cout<<"Enter a number: ";
    cin>>num;
    table(num,c,res);
    return 0;
}
void table(int num, int c, int res)
{
    if(c<=10)
    {
        res=num*c;
        cout<<res<<endl;
        table(num,c+1,res);
    }
}

Output of C C++ program to generate table of number using recursion

C C++ program to generate table of number using recursion

More recursion programs in C C++

  1. Series of natural numbers
  2. Factorial of number
  3. Power of number
  4. Fibonacci series
Share it to:

C C++ program to generate natural numbers using recursion

C C++ program to generate natural numbers using recursion

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

Function क्या है इसका प्रयोग क्यो किया जाता है यह कितने प्रकार का होता है जानने के लिए देखें—Functions in C

Function में call by value और call by reference क्या होता है जानने के लिए देखें—Call by value and reference

C program to generate natural numbers using recursion

#include<stdio.h>
void display(int);
int main()
{
    int num=1;
    display(num);
    return 0;
}
void display(int x)
{
    if(x<=5)
    {
        printf("%d\n",x);
        display(x+1);
    }
}

C++ program to generate natural numbers using recursion

#include<iostream>
using namespace std;
void display(int);
int main()
{
    int num=1;
    display(num);
    return 0;
}
void display(int x)
{
    if(x<=5)
    {
        cout<<x<<endl;
        display(x+1);
    }
}

Output of C C++ program to generate natural numbers using recursion

C C++ program to generate natural numbers using recursion

Other recursion programs in C C++

  1. Table of number
  2. Factorial of number
  3. Power of number
  4. Fibonacci series
Share it to:

Strcmp() function example program in C C++

Strcmp() function example program in C C++

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C-Language में Operator Precedence और Associativity Rule क्या होता है जानने के लिए देखें— Precedence and Associativity in C

Strcmp() function example program in C

#include<stdio.h>
#include<string.h>
int main()
{
    char str1[20],str2[20];
    int dif;
    printf("Enter string1 : ");
    scanf("%s",&str1);
    printf("Enter string2 : ");
    scanf("%s",&str2);
    dif=strcmp(str1,str2);
    if(dif==0)
        printf("Same string");
    else
        printf("Not a same string");
    return 0;
}

Strcmp() function example program in C++

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char str1[20],str2[20];
    int dif;
    cout<<"Enter string1 : ";
    cin>>str1;
    cout<<"Enter string2 : ";
    cin>>str2;
    dif=strcmp(str1,str2);
    if(dif==0)
        cout<<"Same string";
    else
        cout<<"Not a same string";
    return 0;
}

Output of Strcmp() function example program in C C++

Strcmp() function example program in C C++

Related string based programs in C C++

  1. String input-output without space
  2. String input-output with space
  3. Strlwr() function example program
  4. Strupr() function example program
  5. Strlen() function example program
  6. Strrev() function example program
  7. Strcpy() function example program
  8. Strcat() function example program
  9. String and Pointer
Share it to:

Strcat() function example program in C C++

Strcat() function example program in C C++

C में Pointer और String एक दूसरे से कैसे संबंधित होते है और एक साथ कैसे प्रयोग में लाए जाते है जानने के लिए देखें—  Pointer and String

C में फाईल पर इनपुट आउटपुट करने के लिए उपलब्ध विभिन्न प्रकार के Functions को जानने के लिए देखें— File Input Output Functions

C Language में Union क्या होता है और यह Structure से किस तरह भिन्न है जानने के लिए देखें—Unions in C

Strcat() function example program in C

#include<stdio.h>
#include<string.h>
int main()
{
    char str1[20],str2[20];
    printf("Enter string1    : ");
    scanf("%s",&str1);
    printf("Enter string2    : ");
    scanf("%s",&str2);
    strcat(str1,str2);
    printf("Value of string1 : %s\n",str1);
    printf("Value of string2 : %s\n",str2);
    return 0;
}

Strcat() function example program in C++

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char str1[20],str2[20];
    cout<<"Enter string1    : ";
    cin>>str1;
    cout<<"Enter string2    : ";
    cin>>str2;
    strcat(str1,str2);
    cout<<"Value of string1 : "<<str1<<endl;
    cout<<"Value of string2 : "<<str2<<endl;
    return 0;
}

Output of Strcat() function example program in C C++

Strcat() function example program in C C++

Useful string handling programs in C C++

  1. String input-output without space
  2. String input-output with space
  3. Strlwr() function example program
  4. Strupr() function example program
  5. Strlen() function example program
  6. Strrev() function example program
  7. Strcpy() function example program
  8. Strcmp() function example program
  9. String and Pointer
Share it to:

Strcpy() function example program in C C++

Strcpy() function example program in C C++

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

Strcpy() function example program in C

#include<stdio.h>
#include<string.h>
int main()
{
    char str1[20],str2[20];
    printf("Enter a string   : ");
    scanf("%s",&str1);
    strcpy(str2,str1);
    printf("Value of string1 : %s\n",str1);
    printf("Value of string2 : %s\n",str2);
    return 0;
}

Strcpy() function example program in C++

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char str1[20],str2[20];
    cout<<"Enter a string   : ";
    cin>>str1;
    strcpy(str2,str1);
    cout<<"Value of string1 : "<<str1<<endl;
    cout<<"Value of string2 : "<<str2<<endl;
    return 0;
}

Output of Strcpy() function example program in C C++

Strcpy() function example program in C C++

Some other string function examples in C C++

  1. String input-output without space
  2. String input-output with space
  3. Strlwr() function example program
  4. Strupr() function example program
  5. Strlen() function example program
  6. Strrev() function example program
  7. Strcat() function example program
  8. Strcmp() function example program
  9. String and Pointer
Share it to:

C C++ program to swap values of two variable using pointer

C C++ program to swap values of two variable using pointer

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

C Language में उपलब्ध विभिन्न प्रकार के Pointers और उनके उपयोग को जानने के लिए देखें—Types of Pointer in C

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C program to swap values of two variable using pointer

#include<stdio.h>
int main()
{
    int n1,n2,*p1,*p2,temp;
    printf("Enter number1: ");
    scanf("%d",&n1);
    printf("Enter number2: ");
    scanf("%d",&n2);
    p1=&n1;
    p2=&n2;
    temp=*p1;
    *p1=*p2;
    *p2=temp;
    printf("Number1 = %d\n",n1);
    printf("Number2 = %d\n",n2);
    return 0;
}

C++ program to swap values of two variable using pointer

#include<iostream>
using namespace std;
int main()
{
    int n1,n2,*p1,*p2,temp;
    cout<<"Enter number1: ";
    cin>>n1;
    cout<<"Enter number2: ";
    cin>>n2;
    p1=&n1;
    p2=&n2;
    temp=*p1;
    *p1=*p2;
    *p2=temp;
    cout<<"Number1 = "<<n1<<endl;
    cout<<"Number2 = "<<n2<<endl;
    return 0;
}

Output of C C++ program to swap values of two variable using pointer

C C++ program to swap values of two variable using pointer

List of important pointer example programs in C C++

  1. Declaration and assignment of pointer
  2. Pointer to pointer
  3. Sum of two numbers using pointer
  4. Average of three numbers using pointer
  5. Pointer Arithmetic
Share it to:

C C++ program to find average of three numbers using pointer

C C++ program to find average of three numbers using pointer

C Language की विशेषताओं एवं शक्तियों को जानने के लिए देखें—Features and Powers of C

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

Object Oriented Programming (OOP) की विभिन्न अवधारणाओं को जानने के लिए देखें—Concepts of OOP

C program to find average of three numbers using pointer

#include<stdio.h>
int main()
{
    int n1,n2,n3,*p1,*p2,*p3;
    float avg;
    printf("Enter three numbers: ");
    scanf("%d%d%d",&n1,&n2,&n3);
    p1=&n1;
    p2=&n2;
    p3=&n3;
    avg=(*p1+*p2+*p3)/3.0;
    printf("Average = %f",avg);
    return 0;
}

C++ program to find average of three numbers using pointer

#include<iostream>
using namespace std;
int main()
{
    int n1,n2,n3,*p1,*p2,*p3;
    float avg;
    cout<<"Enter three numbers: ";
    cin>>n1>>n2>>n3;
    p1=&n1;
    p2=&n2;
    p3=&n3;
    avg=(*p1+*p2+*p3)/3.0;
    cout<<"Average = "<<avg;
    return 0;
}

Output C C++ program to find average of three numbers using pointer

C C++ program to find average of three numbers using pointer

Useful pointer programs in C C++

  1. Declaration and assignment of pointer
  2. Pointer to pointer
  3. Sum of two numbers using pointer
  4. Swapping two variables using pointer
  5. Pointer Arithmetic
Share it to:

C C++ program to find sum of two numbers using pointer

C C++ program to find sum of two numbers using pointer

Pointer और इसके कार्य करने के तरीके को आधिक जानने के लिए देखें यह पोस्ट—Pointers in C

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

C-Language में Operator Precedence और Associativity Rule क्या होता है जानने के लिए देखें— Precedence and Associativity in C

C program to find sum of two numbers using pointer

#include<stdio.h>
int main()
{
    int n1,n2,*p1,*p2,sum;
    printf("Enter two numbers: ");
    scanf("%d%d",&n1,&n2);
    p1=&n1;
    p2=&n2;
    sum=*p1+*p2;
    printf("Sum = %d",sum);
    return 0;
}

C++ program to find sum of two numbers using pointer

#include<iostream>
using namespace std;
int main()
{
    int n1,n2,*p1,*p2,sum;
    cout<<"Enter two numbers: ";
    cin>>n1>>n2;
    p1=&n1;
    p2=&n2;
    sum=*p1+*p2;
    cout<<"Sum = "<<sum;
    return 0;
}

Output of C C++ program to find sum of two numbers using pointer

C C++ program to find sum of two numbers using pointer

Important pointer programs in C C++

  1. Declaration and assignment of pointer
  2. Pointer to pointer
  3. Average of three numbers using pointer
  4. Swapping two variables using pointer
  5. Pointer Arithmetic
Share it to: