please in form of printf and scanff,,,, c++ please Not java ECE 270 Computer Met
ID: 3750512 • Letter: P
Question
please in form of printf and scanff,,,, c++ please Not java
ECE 270 Computer Methods in ECE InClass Quiz #2 September 19, 2018/ Instructor: Paul Watta Write a program for the following game. Your program generates a ir the numberheyi by multiplying asked to enter a divisor of the challenge number. The user wins Ivisor. Otherwise, they lose $5. To ensure that the challenge num n S and 1o,the challenge number has divisors, create it by multiplying Challenge number: 100 Enter a divisor: 25 100 is divisible by 25! You win $5Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int num1 = (rand() % (5 - 10 + 1)) + 5; // generate random number between 5 and 10
int num2 = (rand() % (5 - 10 + 1)) + 5; // generate random number between 5 and 10
int x=num1*num2; // multiply both random number
int d;
printf("Challenge number:%d ",x);
printf("Enter a Divisor: ");
scanf("%d",&d);// enter Devisor
printf("%d ",d);
if(x%d==0)
printf("%d is devisible by %d ! you win $5! ",x,d);
else
printf("%d is not devisible by %d ! you lose $5! ",x,d);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.