Skip to main content

How to get division of 2 integer number in c language. || division program in c language.

  How to get a division of 2 numbers in c language. Division of two integer number in c Division of 2 integer number:     here we want to get a division of 2 number so for that we have to take 3 variable  1st is for Dividend, 2nd is for divisor and, 3rd is for an answer.     the simple logic is  a= b/c.     here variable "a" get value which is the division of b and c in other words we can say that a is the answer of b divide by c. we show you to way to get an answer. 1) In this way, we have to just take the answer in 3rd variable, and then after we have to print that variable. hear we take div as answer variable. Example:: #include<stdio.h> #include<conio.h> void main() {     int a,b,div;     clrscr();     printf("\nWelcome,CoderFact\n---------------Division---------------");     printf("\nEnter a First Number(Divisior) :");     scanf("%d",&a);     printf("\nEnter a S...

How to get division of 2 integer number in c language. || division program in c language.

 

How to get a division of 2 numbers in c language.

Title Blog image
Division of two integer number in c


Division of 2 integer number:

    here we want to get a division of 2 number so for that we have to take 3 variable 

1st is for Dividend, 2nd is for divisor and, 3rd is for an answer.

    the simple logic is  a= b/c.

    here variable "a" get value which is the division of b and c in other words we can say that a is the answer of b divide by c.

we show you to way to get an answer.

1)

In this way, we have to just take the answer in 3rd variable, and then after we have to print that variable.

hear we take div as answer variable.

Example::



#include<stdio.h>

#include<conio.h>


void main()

{

    int a,b,div;

    clrscr();

    printf("\nWelcome,CoderFact\n---------------Division---------------");

    printf("\nEnter a First Number(Divisior) :");

    scanf("%d",&a);

    printf("\nEnter a Second Number(Dividend):");

    scanf("%d",&b);

    div=a/b;

    printf("\n--------------Answer--------------\nTwo Number Division(Quotient) is %d",div);

    getch();

}



OUTPUT::
















here we get Anser 5 as a division of 25 by 5.


2)
 In this way, we don't need of 3rd variable to hold an output we can simply write the logic of the division method in the printf statement where we want to print our answer.

ex:
printf("Divison of 2 number is %d",a/b);
here we directly pass logic instead of value. so it can reduce some code.

Example::


#include<stdio.h>

#include<conio.h>


void main()

{

    int a,b;

    clrscr();

    printf("\nWelcome,CoderFact\n---------------Division---------------");

    printf("\nEnter a First Number(Divisior) :");

    scanf("%d",&a);

    printf("\nEnter a Second Number(Dividend):");

    scanf("%d",&b);

    printf("\n--------------Answer--------------\nTwo Number Division(Quotient) is %d",a/b);

    getch();

}

OUTPUT::

















so you can see that this method is also working as same as previous one. and we get an answer is 5 as an output.


         We hope you understand this topic if you have any queries related to this topic you can write your question and queries in the comment section we will solve them out as soon as possible. stay connected with us for more topics and program like this and if you have some special requirement or you want any Query about other language codes then also you can directly contact us.
Thank you.



Comments

Popular posts from this blog

How to Convert Integer To HexaDecimal and HexaDecimal To Integer in c || 1 line code

   Integer To HexaDecimal Example :: #include<stdio.h> #include<conio.h> void main() {     int no;     clrscr();     printf("\nWelcome,CoderFact");     printf("\nEnter a Integer number : ");     scanf("%d",&no);     printf("Hexadecimal number is :  %x",no);     getch(); } Output :: Output of program  HexaDecimal  To Integer  in c Example :: #include<stdio.h> #include<conio.h> void main() {     int no;     clrscr();     printf("\nWelcome,CoderFact");     printf("\nEnter a  Hexadecimal  number : ");          scanf("%x",&no);     printf("Integer number is :  %d",no);     getch(); } Output ::

How to print folat numbers in c language and what are the formation of float variable.

How to print float number in c language.  Floating numbers are basically real numbers.  if we want to print folat numbers in c language for that we have to take %f as keyword in printf and scanf function.  Example : For scanning: Scanf("%f",&variable name); For printing: Printf("foat num is %f.",variable name); There are Diffrent formats  to print float number in c language. Hear we take 1 example which shows you that if we want to print 2 digit after "." Than we have to just write " .2 " in calling printf sattment.  Example: #include<stdio.h> #include<conio.h> void main() {     float a;     clrscr();     printf("\nWelcome,CoderFact");     printf("\nEnter a number : ");     scanf("%f", &a);     printf("Your entered a number is :  %.2f " , a);     getch(); } OUTPUT:: Hear we pass value 12 and we get output  12.00 this thing is occur due to we take input as float nu...

Useful Formula for Programmar

  Simple Interest  ::                                     Si =(p* n*r)/100 Area of Square ::                                                          Area =side* side Area of Rectangle ::                                                           Area = length * breadth Area of Right angled triangle ::                                               Area =(...