This is what I have so far, but I can\'t seem to get the answer toprint correctl
ID: 3617556 • Letter: T
Question
This is what I have so far, but I can't seem to get the answer toprint correctly. If the first integer divides evenly into thesecond one, it should print the correct answer and exit afterward.If it is not an even division, it should keep asking for numbersuntil it scans and find one that works. Thanks./*
Design an interactive input loop that scans pairs of integers untilit reaches a pair in which the first integer evenly divides thesecond.
*/
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
int a; /* first integer */
int b; /*second integer */
int division;
do{
printf("Enter twointegers: ");
scanf("%d%d",&a,&b);
division = a % b;
}while(division !=0);
printf("%d ",&division);
system("pause");
return(0);
}
Explanation / Answer
please rate - thanks add error checking /* Design an interactive input loop that scans pairs of integers until it reaches a pair in which the first integer evenly dividesthe second. */ #include #include int main(void) { int a; /* first integer */ int b; /*second integer */ int division; do{ printf("Enter the firstinteger:"); scanf("%d",&a); while(a==0) {printf("invalid entry-cannot divide by 0 "); printf("Enter the first integer:"); scanf("%d",&a); } printf("Enter the secondinteger: "); scanf("%d",&b); division = b % a; }while(division != 0); printf(" %d evenly divides %d ", a,b); system("pause"); return(0); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.