C language code for subtraction of two numbers




SUBTRACTION OF TWO NUMBERS

SIMPLE C LANGUAGE CODE FOR SUBTRACTION OF TWO NUMBERS:

#include<stdio.h>
#include<conio.h>
int main()
{int a, b, c;//we take two integer value
printf("Enter the number :");//use to print the letter, character
scanf("%d%d",&a,&b);//use to scan the accept number and scan it
c=a-b;//arithmetic logical operation, formula
printf("Ans=%d\n", c)/*use to perform operation and display answer*/
getch();
}

And save with extension .c
for eg.
SUB.c//SUB is the name of the file and .c is an extension of the file.
           In the above example, we can subtract integer numbers not fractional numbers. for example when output screen comes type two numbers like 2 and press enter then type next numbers like 6 then press enter the answer print on the output screen.
            This code is for integer numbers, if we want to subtract fractional numbers then in above code small changes is there i.e.in the place of int type float and at the place of % d type % f.For subtraction of fractional numbers the code is as follow:

SUBTRACTION OF TWO FRACTIONAL NUMBERS:
#include<stdio.h>
#include<conio.h>
float main()
{flaot a, b, c;//we take two fractional value
printf("Enter the number :");//use to print the letter, character
scanf("%f%f",&a,&b);//use to scan the accept number and scan it
c=a-b;//arithmetic logical operation, formula
printf("Ans=%f\n", c)/*use to perform operation and display answer*/
getch ();
}

Friends in most trades maths are the most important factor escape some courses.MATHEMATICS is one type of magic so we must make a maths magician then automatically we made our life magician.
         Friends if you like my blogs then please write a comment in the comment box.



C language code for subtraction of two numbers C language code for subtraction of two numbers Reviewed by Amit Waghmare on September 15, 2018 Rating: 5

No comments: