LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2012, 08:48 PM   #1
Chris4610
LQ Newbie
 
Registered: Nov 2012
Posts: 5

Rep: Reputation: Disabled
Talking Can't figure out these questions


Hello Everyone,

I had posted needing help and I hope to get it worked out, but there is something else I'm desperate for some help. I've been seriously sick with the flu so I could use some help as this script stuff really boggles my mind at times. Below I will post the questions i was needing help with.

tyvm,

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.
 
Old 11-08-2012, 09:38 PM   #2
Chris4610
LQ Newbie
 
Registered: Nov 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Please if anyone can help me with these questions, I've been fine until now and if I can get help I should be ok after.

Ty

Chris
 
Old 11-09-2012, 05:38 AM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
You ain't impatient, ain't you? Give it time to go around the world (24 hours).

Please be more clear in what you don't understand. This looks a lot like C (and not scripting) so a book on C (or online tutorials) might be what you need more at this moment than our help

Let me help you with question 2; what does a switch statement do?
Feed a number in it (x); if (initial) x equals 0, case 0 is executed followed by case 1 (because there is no break after case 0). If (initial) x equals 1, case 1 is executed. If x equals something else, the default case is executed.

And for 1 and 3, do a search for C function declaration syntax; I found this one that might be easy to understand: http://en.wikipedia.org/wiki/C_syntax#Syntax but a tutorial somewhere might be better.

Please show us what you coded (for questions that require you to code) and we can help you to fix your code if you don't understand what you do wrong.

Last edited by Wim Sturkenboom; 11-09-2012 at 05:55 AM.
 
1 members found this post helpful.
Old 11-09-2012, 08:32 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
Quote:
Originally Posted by Wim Sturkenboom View Post
Let me help you with question 2;
That was more than you ought to have done for what appears to be a take home test (maybe just homework, but I have reason to suspect take home test).

Someone who got that far in a programming class without doing the work ought to flunk.

BTW, a quick check with google showed me both that the instructor is lazy and that the OP doesn't know how to use google when cheating.

Last edited by johnsfine; 11-09-2012 at 08:37 AM.
 
2 members found this post helpful.
Old 11-09-2012, 09:21 AM   #5
Chris4610
LQ Newbie
 
Registered: Nov 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
It is homework and not a test,also I am needing help because it's just something I have never fully understood. But also lately i've had to deal with my mother in law and father in law almost dying so I have fallen behind in my work and just need help to catch up that is all.
 
Old 11-09-2012, 09:39 AM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
Quote:
Originally Posted by Chris4610 View Post
I am needing help because it's just something I have never fully understood. But also lately i've had to deal with my mother in law and father in law almost dying so I have fallen behind in my work and just need help to catch up that is all.
I'm sorry for all your personal troubles. Maybe you should ask your instructor for extra time.

But that is not a reason to ask us to do your homework for you.

I and others are happy to help if you start by making some effort yourself, but are then confused by specific details. But just posting the original question and asking us to do it for you is wrong. Posting a whole list of original questions is even worse.
 
Old 11-09-2012, 09:50 AM   #7
jkirchner
Member
 
Registered: Apr 2007
Location: West Virginia
Distribution: LinuxMint
Posts: 775

Rep: Reputation: 199Reputation: 199
Quote:
Originally Posted by Chris4610 View Post
Please if anyone can help me with these questions, I've been fine until now and if I can get help I should be ok after.

Ty

Chris
If you want any help at all, the least you could do is post what you have attempted already and asked specific questions. The way you did it looks like you just want someone to do your work for you.

Also, you agreed to LQ rules when you signed up. Here is a refresher of one of the rules:

Quote:
•Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
As for this.....

Quote:
But also lately i've had to deal with my mother in law and father in law almost dying so I have fallen behind in my work and just need help to catch up that is all.
Sorry to hear you are having troubles. I do hope things are getting better. I agree with johnsfine's advice though, this would be something to take to your instructor to get more help/time.

Last edited by jkirchner; 11-09-2012 at 11:38 AM.
 
Old 11-09-2012, 12:04 PM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by johnsfine View Post
That was more than you ought to have done for what appears to be a take home test (maybe just homework, but I have reason to suspect take home test).
It was just explaining. And I think that that is what we're here for
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
not able to figure out what does this mean manya Programming 5 11-29-2009 10:45 PM
trying to figure this out? dale504 Linux - Newbie 2 02-27-2008 10:04 AM
cant figure out megadsonic Linux - Networking 7 12-18-2005 02:19 AM
Some questions i need to figure out, help. levi Linux - Newbie 13 02-10-2003 09:30 PM
Newbies questions, figure newtons2k Linux - Newbie 3 11-20-2002 06:23 PM


All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration