Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COMP 1098 Midterm Fall 2022 1) (10 marks) Write a function named abs val that returns the absolute value of an int passed to
COMP 1098 Midterm Fall 2022 1) (10 marks) Write a function named abs val that returns the absolute value of an int passed to it by value. You cannot use the abs() function library. 2) (10 marks) Write a rangeSum function which Prompt the user for two positive integers a and b. (asks for input) Write a separate function, rangeSum to compute the sum of the consecutive integers from a to b inclusive (that includes both a and b). The rangeSum function should only calculate the sum. It should print a, b and sum. Example: a = 5, b = 7. Output is a is 5, b is 7, sum is 18. 3) Short answers and theoretical questions (2 marks each) a) What initial value should be assigned to b at line 6 so that the output of this program is 10? public static void Main(string[] args) { int sum=0; int n=1; int b; { } b=??; while (n
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started