Answer to Question #21844 in C# for tofik mohamed

Question #21844
write a static method with one integer parameter and let it return the remainder of that integer when divided by 7. for example,findremainder(19)should return 5.in the main method, initilalize two variables, x and ,with values 73 and 16.call the find remainder method three times,with the argument x,y and x+y,each time displaying the result returned by findremainder.
Additionally, illustrate how the unary operators ++ and -- work, each being placed before and after the variable name. Apply those operators to the variables x and y described in the exercise (you will need to make additional FindRemainder calls).
1
Expert's answer
2013-01-11T04:31:33-0500
& static int findReminder(int x)
& {
return x % 7;
& }
&
static void Main(string[] args)
& {
int x = 73;
int y = 16;
&
Console.WriteLine(findReminder(x));
&
Console.WriteLine(findReminder(y));
&
Console.WriteLine(findReminder(x+y));

& //The ++ operation is called "increment"
//It increases the variable's value& by 1. Prefix and postfix form has some differences
&
//Postfix:
//Firstly the variable is used and then increases
Console.WriteLine(findReminder(x++));
&
//Prefix:
//Firstly the variable increases and then is used
Console.WriteLine(findReminder(++x));
&


//The -- operation is called "decrement"
//It reduces the variable's value by 1.
//The difference between postfix and prefix form is similar to increment operation
&
//Postfix:
Console.WriteLine(findReminder(y--));
//Prefix:
Console.WriteLine(findReminder(--y));
& }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS