Hello, I need nelp with this program. (The project from problem solving and prog
ID: 3604169 • Letter: H
Question
Hello, I need nelp with this program. (The project from problem solving and program design in C), please follow the assignment requirements.
1. Complete the MODIFIED programming project 1 in Page 306 with the following implementation requirements. You must get the number from the user. When you read the number entered by the user, read it as a whole number, not digit by digit like in Question 2 in Part 1. . Your program must display each digit in the number (separating the digits using at least 1 space) and display whether the number is divisible by 9 or not. Hints: You need a conditional loop to check if you have done processing all digits. Using a while loop is easier than for loop in this problem. So pac e assples of whate loop are in Figure 5.4 in Page 243 and in Page 256Explanation / Answer
/************************************************ExtractDigits.c************************************/
#include<stdio.h>
// main function start
int main() {
int num,temp,rem,sum=0;
printf("Please Enter the number:");
scanf("%d",&num);
//extracting each digit of number
temp=num;
printf("Digits are: ");
while(temp!=0) {
rem=temp%10;
printf("%d ",rem);
sum+=rem;
temp/=10;
}
printf(" ");
// number is divisible by 9 or not
// if sum of digits of number is divisible by 9 or not
if(sum%9==0) {
printf("Number %d is divisible by 9 ",num);
}else {
printf("Number %d is not divisible by 9 ",num);
}
return 0;
}//Main function end
/*******************************************output*******************************************/
C:UserslmaliDesktopChegg>g++ ExtractDigit.c
C:UserslmaliDesktopChegg>a.exe
Please Enter the number:154368
Digits are: 8 6 3 4 5 1
Number 154368 is divisible by 9
C:UserslmaliDesktopChegg>a.exe
Please Enter the number:621594
Digits are: 4 9 5 1 2 6
Number 621594 is divisible by 9
C:UserslmaliDesktopChegg>a.exe
Please Enter the number:123456
Digits are: 6 5 4 3 2 1
Number 123456 is not divisible by 9
Thanks a lot. Please let me know if you have any doubt.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.