Get the App
SLTechnology News&Howtos  ›  Development  › 

How to divide two numbers in C language

Shulou Source: shulou.com Published: 2022-06-01 01:51:01 09月30日 Update

This article introduces the relevant knowledge of "how to divide two numbers in C language". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Divide two numbers and, if there is a remainder, output the remainder.

Example

# include

Int main () {

Int dividend, divisor, quotient, remainder

Printf ("enter divisor:")

Scanf ("d", & dividend)

Printf ("enter divisor:")

Scanf ("d", & divisor)

/ / Computing business

Quotient = dividend / divisor

/ / calculate the remainder

Remainder = dividend% divisor

Printf ("quotient =% d\ n", quotient)

Printf ("remainder =% d", remainder)

Return 0

}

Running result:

Input divisor: 5 input divisor: 2 quotient = 2 remainder = 1 "how to divide two numbers in C language" is introduced here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Remainder input language content more knowledge divisor divisor output utility achievement next dilemma example reality situation article case result editing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS Redmi NVidia MariaDB