+2

How would you do a C program

How would you do a C program that asks for two numbers and divides them and displays the result on the console but without using floating or the% f specified only int

c int

2/8/2020 10:48:26 PM

123456

16 Answers

New Answer

+8

IF you just search every task of this exercise you will solve it. You have described the problem perfect. Search for (here in sololearn) : 1. "Input in C" 2. "divide in C" (easy : number1/number2;) 3. "output in C without using %f" Open your IDE in your profile section, click the NEW CODE button, Select as language C and write what you found in 1, 2 ,3 with this order. Click RUN and you will see the results.

+7

to complement blackwinter: 1. & 2. are sure to be found in c course. 3. if it is not mentioned in the c course, try search bar of q&a or google or ask here (but only if you don't find a post in q&a)

+5

+4

O.k i think i have the solution (interesting) For example you have 10 and 3. you do 10/3=3. Then you do 10%3=1=mod. printf(3). Now you do: mod*10/3=3, (mod*10)%3=1=mod , printf("."+3) mod*10/3=3, (mod*10)%3=1=mod , printf(3) ... Another example: 7 and 4 7/4=1 you print 1. 7%4=3 , 3*10/4=7 you print "." + 7. (3*10)%4=2, 2*10/4=5 you print 5. (2*10)%4=0 you stop because division is complete. (zero modulo as result) 3.75 printed.

+3

123456 3.33 converted to int would be 3. if you need 3.33 you should leave it as float

+3

So you need, 10/3=3 but you need this 3.33 without using int. Are u allowed to use modulo %? 10%3=1 Are we allowed to use this ?

+3

Did you solve it?

+3

It is as easy as doing the division by hand. Since the solution has been posted yet, I left you here an example. https://code.sololearn.com/ceb1p2hSxlS4/?ref=app https://code.sololearn.com/cmhrTgEcC2HA/?ref=app

+2

Maybe I should explain with an example, it would be input I have 10 and 3 the output should be 3.33 but without using float only int

+2

Credit to blackwinter, https://code.sololearn.com/cBEE7tCIUomb/?ref=app

+1

Everything except float ni% f is allowed

+1

I still don't have it confusing

+1

Or do you simply need the quotient and integer division only?

0

Привет

0

0