November 22, 2024, 12:56:36 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Programming Help  (Read 19034 times)

Offline Chris4610

  • Linux Noob !
  • *
  • Posts: 8
Programming Help
« on: November 09, 2012, 04:12:06 AM »
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.



Offline Chris4610

  • Linux Noob !
  • *
  • Posts: 8
Re: Programming Help
« Reply #1 on: November 09, 2012, 06:16:26 PM »
First let me apologize for the posting I am asking for help for this one time, I have had to deal with my future mother in law and father in law almost passing away on us and it led me to fall behind a little. I have also been sick with the flu, so if anyone can please help me with this, i would be grateful. I certainly will still pose a question or 2 in the future but this would be the only time i'd ask for this much help.

Ty,

Chris


Offline Chris4610

  • Linux Noob !
  • *
  • Posts: 8
Re: Programming Help
« Reply #2 on: November 09, 2012, 06:52:50 PM »
I thankfully was able to actually work out the answers for the questions I needed help on. But if anyone can please help me with the linux shell scripting post that I made it would really bail me out of a bad mess. I just can't grasp the concept of building scripts by myself.

Ty,

Chris

Offline WarnerChaft

  • New Member
  • Posts: 3
Programming Help
« Reply #3 on: December 28, 2018, 02:48:03 AM »
Can somebody add here Mac Programming and Development Board.
I might have some interesting writings and questions..