Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(USING VISUAL STUDIO) }Do Ch.5 .167 PE 3 DESIGN a program to: Prompt the user to

ID: 2085653 • Letter: #

Question

(USING VISUAL STUDIO)

}Do Ch.5 .167 PE 3

DESIGN a program to:

Prompt the user to enter a number of days, or zero to quit.

Convert the days to weeks and days, and print those out.

Use a while() loop to repeat the process until the user enters a zero or negative #.

Hint: Use integer divide by 7 to get the weeks, and the modulus % to get the odd days left. Similar to listing 5.9, pg. 143.

Example output (with user input shown underlined):

Enter a number of days, or zero to quit: 143

143 days is 20 weeks and 3 days.

Enter a number of days, or zero to quit: 365

365 days is 52 weeks and 1 days.

Enter a number of days, or zero to quit: 0

   Goodbye!

Explanation / Answer

main()

{

int n // number of days

scanf("enter the value of n", n)      //read the value of number of days

        while(n)

        {

          w=n/7;

          d=n%7;

         printf("number of weeks is %d and number of days is %d ", w,d);

          }

printf("Good bye ")                     // if while loop condition, n=0, then it prints Good bye

}