C language code for division of two numbers




DIVISION OF TWO NUMBERS

SIMPLE C LANGUAGE CODE FOR DIVISION 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.
div.c//div is the name of the file and .c is extension of file.
           In the above example, we can divide 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 divide 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 division of fractional numbers the code is as follow:

DIVISION 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 I hope you are learning for my blog , if you have any query then write in comment i will solve it.
In my next blog, I will teach you how to add all operations in one code.


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

No comments: