banner



Use Repeated Subtraction To Divide

#1

dbzx is offline

Registered User


Division using repeated subtraction

Okay and then I am suppose to write a program that divides two numbers without using the operator "/"
So i try writing the program using repeated subtraction, just I dont know if I am doing this right at all.

Heres my code

Lawmaking:

#include <stdio.h>  int main() {         int a, b, max, min, results, count;         max = 2000000000;         min = -2000000000;         results = 0;         count = 0;          printf("Enter integer numbers 'a' and 'b' for division a/b: ");         scanf("%d %d", &a, &b);          if (b == 0) {                 printf("Sectionalization by zero is non allowed!");         		printf("\n");         		return 0;         }		         while (i) {                 results = a - b;                 count++;                 if (b < a)                         pause;         }         printf("Partition outcome is %d\n", count);         return 0;


#2

quzah is offline

ATH0 quzah's Avatar


B is never going to be less than A unless it is to first with, considering you aren't actually changing B or A. You're doing:

C = A - B
D++

And then are checking to see if B is less than A, without ever really changing anything other than C and D.

Quzah.

Promise is the first step on the road to disappointment.


#10

ಠ_ಠ is offline

Banned ಠ_ಠ's Avatar


Quote Originally Posted past tropche View Post

i think i did correct to bring a possible solution to this problem.

no yous did not

at least have some respect for me as a new member....

ಠ_ಠ

╔╗╔══╦╗
║║║╔╗║║
║╚╣╚╝║╚╗
╚═╩══╩═╝


Use Repeated Subtraction To Divide,

Source: https://cboard.cprogramming.com/c-programming/114517-division-using-repeated-subtraction.html

Posted by: jamesfiect1953.blogspot.com

0 Response to "Use Repeated Subtraction To Divide"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel