In this tutorial, we will discuss the Use of C program to subtraction of two numbers using the recursion
In this topic, we are going to learn how to subtract two numbers (integer )using the recusive function in C language
already we are learned the same concept using the operator
if you want to remember click here, C program to subtract two numbers
The program allows to enter two integer numbers and then it calculates the subtraction of the given numbers using recursive function of C language
Program 1
#include <stdio.h> #include <stdlib.h> int sub(int,int);//function prototype int main() { int num1,num2;//declare te variables printf("Enter two numbers: \n"); scanf("%d%d",&num1,&num2);//read te value input from user printf("Subtraction of two numbers : %d",sub(num1,num2));//call the function getch(); return 0; } int sub(int num1, int num2)//define the recursive function { if(num2==0) return num1; else return sub((num1-1),(num2-1)); }
When the above code is executed, it produces the following result
Enter two numbers: 1200 500 Subtraction of two numbers : 700
Approach
Suggetsed post
Similar post
Subtract two numbers in Java language
Subtract two numbers in C++ language
Subtract two numbers in Python language
Subtract two numbers in Java language using method
Subtract two numbers in C language using function
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…
View Comments
Hi, I would like to subscribe for this website to take newest updates, therefore where can i do it please help. Suzanne Talbot Valeda