In this article, we will discuss the concept of the C program to find Subtraction of two numbers
In this post, we are going to learn how to write a program find the subtraction of two numbers in C programming language
The program use to find subtraction of given two integer numbers
Program 1
#include <stdio.h> #include <stdlib.h> int main() { int num1=54,num2=67; //variable declaration and initialization int sub=num2-num1; //formula of subtraction printf("Difference of two numbers are: %d\n",sub); //display the result getch(); return 0; }
When the above code is executed, it produces the following result
Difference of two numbers are: 13
This program allows the user to enter two numbers Then the program find the subtraction of the given two number
Program 2
#include <stdio.h> #include <stdlib.h> int main() { int num1,num2; //variable declaration printf("Enter the first number: "); scanf("%d",&num1); //read the first number printf("Enter the second number: "); scanf("%d",&num2); //read the second number int sub=num2-num1; //formula of subtraction printf("Differences of two numbers are: %d\n",sub); //display the result getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter the first number: 65 Enter the second number: 87 Differences of two numbers are:22
Case 2
Enter the first number: 90 Enter the second number:73 Differences of two numbers are:-23
The program use to find subtraction of given two floating point numbers
Program 3
#include <stdio.h> #include <stdlib.h> int main() { float num1=54.53,num2=67.45; //variable declaration and initialization float sub=num2-num1; //formula of subtraction printf("Difference of two float numbers are: %.2f\n",sub); //display the result getch(); return 0; }
When the above code is executed, it produces the following result
Difference of two float numbers are:12.92
This program allows the user to enter two float numbers Then the program find the results of subtraction the given two number
Program 4
#include <stdio.h> #include <stdlib.h> int main() { float num1,num2; //variable declaration printf("Enter the first number: "); scanf("%f",&num1); //read the first number printf("Enter the second number: "); scanf("%f",&num2); //read the second number float sub=num2-num1; //formula of subtraction printf("Differences of two numbers are: %.2f\n",sub); //display the result getch(); return 0; }
When the above code is executed, it produces the following result
Case 1
Enter the first number: 43.6 Enter the second number: 67.8 Differences of two numbers are:24.20
Case 2
Enter the first number: 65.4 Enter the second number:35.8 Differences of two numbers are:-29.60
Suggested for you
Similar post
Find sum of two numbers in C using recursion
Find sum of two numbers in C using pointer
Find sum of two numbers in C without Arithmetic operator
Find sum of natural numbers in C language
Find sum of natural numbers in C language using recursion
How to find reverse number using method In this article, we will discuss the concept…
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…