+ 3

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

8th Feb 2020, 10:48 PM
123456
123456 - avatar
17 odpowiedzi
+ 10
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.
8th Feb 2020, 11:00 PM
Black Winter
+ 8
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)
8th Feb 2020, 11:07 PM
Denise Roßberg
Denise Roßberg - avatar
+ 6
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.
8th Feb 2020, 11:53 PM
Black Winter
+ 5
Have you tried?
8th Feb 2020, 11:00 PM
Mihai Apostol
Mihai Apostol - avatar
+ 5
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 ?
8th Feb 2020, 11:41 PM
Black Winter
+ 4
123456 3.33 converted to int would be 3. if you need 3.33 you should leave it as float
8th Feb 2020, 11:29 PM
Denise Roßberg
Denise Roßberg - avatar
+ 4
Did you solve it?
9th Feb 2020, 12:27 AM
Black Winter
+ 3
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
8th Feb 2020, 11:28 PM
123456
123456 - avatar
9th Feb 2020, 6:03 AM
LastSecond959
LastSecond959 - avatar
+ 2
Everything except float ni% f is allowed
8th Feb 2020, 11:44 PM
123456
123456 - avatar
+ 2
I still don't have it confusing
9th Feb 2020, 12:47 AM
123456
123456 - avatar
+ 2
Or do you simply need the quotient and integer division only?
10th Feb 2020, 10:15 PM
Sonic
Sonic - avatar
+ 1
This is late, but I see no accepted solution yet. Did you consider using fixed point representation? For example, if you want 3 decimal points of precision, multiply the input integer values by 1000 in order to shift them to the left by 3 decimal places. Then use integer division. Process the output as needed to display the decimal between the third and fourth digits from the right-hand side.
21st Sep 2020, 12:50 PM
Brian
Brian - avatar
0
Have you done it
10th Feb 2020, 7:48 AM
SLPZfragz
- 1
Pr
10th Feb 2020, 11:47 AM
Scripting_boom
Scripting_boom - avatar
- 2
Привет
10th Feb 2020, 6:59 AM
KirillRut