Hello,
I am in need of some help with several programming questions, I am truly lost so if someone can please help me i'd be greatful.
Ty,
Chris
1. Declare a function that is called Compute_Avg. The function returns a float data, receives an integer parameter named “num”, and a float parameter named “Average”.
2. x = 2, y =1, z =3, what is the value of x, y, z after executing the following codes?
switch(x)
{
case 0: x =2; y =3;
case 1: x =3; break;
default: x=3; y=2 ;
}
3. Find any errors in the following function declarations.
a. int sun(int x, y);
b. int sun(int x, int y)
c. void sun(void, void) ;
d void sun(x int, y float);
4. What is the output of the code corresponding to the following pseudocode?
(a)
X = -5;
if (X > 0)
printf(“%d”,X);
if (!((X=0) && (X<0)))
printf(“Not”);
(b)
#include<stdio.h>
#include<stdlib.h>
void print_message(void);
int main()
{
print_message( );
printf(“This is a new message.\n”);
print_message( );
print_message( );
printf(“The end.\n”);
system(“pause”);
return 0;
}
void print_message( )
{
printf(“Hello !\n”);
return;
}
5. If num=5, determine whether each of the following expressions is true or false.
a. (num*num)>=(2*num)
b. (3*num-2)<=6
6. A home mortgage authority requires a deposit on a home loan according to the following schedule:
Loan$ Deposit
Less than $25000 6% of loan value
$25000-$49000 $1000+10% of loan
$49000-$100000 $2000+25% of loan
Loans in excess of $100000 are not allowed. Write a program that will read a loan amount and compute and print the required deposit.
7 Write a program that inputs one number, then display “yes” if num = 1, display “no” if num =2, displays “maybe” if num = 3, display “Error message” if num is not 1,2 or 3. Implement this program by a Switch statement.
8. Write a function float Average(int, int, int, int) that finds the average of four numbers, and then write a main program that inputs four numbers from the user. You need to call the function and display the mean of the four numbers in the main.
The cost of renting a tool is $20 for the first day, $10 per day for the next 3 days and $8 per day thereafter. If the input is the number of days the tool was rented, compute the cost of renting the tool.