Answered! Please help me create a psuedocode for the following questions… "mod" is the remainder function…

Please help me create a psuedocode for the following questions…

“mod” is the remainder function

it is the remainder that results when a non zero integer divides another integer.

suppose m mod n = r and m/n = q where m,n,q, and r are integers then m = q x n + r

9 mod 2 = 1 and 9 = 4 x 2 + 1

8 mod 2 = 0 and 8 = 4 x 2 + 0

8 mod 3 = 2 and 8 = 2 x 3 + 2

11 mod 7 = 4 and 11 = 1 x 7 + 4

22 mod 7 = 1 and 22 = 3 x 7 + 1

What is the output of the following program fragment?

num = 12

while num >= 0

if num mod 5 = 0 then

add 1 to num

else

display num

subtract 2 from num

end if

end while

Expert Answer

 pseudocode :

main()

{
integer m,n,r,q;
Read in m and n;

Calculate m%n and set it to r;

Write r;

Calculate m/n and set it to q;

Write q;

Check m=q*n+r

Write m;
}

Program:

#include <iostream>
#include <string>
using namespace std;
int main()
{
int num=12;

while(num>=0)
{
if(num%5==0)
num++;
else
cout<<” “<<num;
num=num-2;
}
}

Output:

12 9 7 4 2

Still stressed from student homework?
Get quality assistance from academic writers!