LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-22-2012, 09:41 PM   #1
carlosk711
Member
 
Registered: Sep 2012
Posts: 52

Rep: Reputation: Disabled
Can some one explain what I'm supposed to do in this assignment??


For this assignment you will modify the values of the arguments to a function in that function. I have provided you with a part of the main function below. Your task is to complete the main function and write the function fill. There are comments to guide you.
int main() {
int pi, e, gr;

fill(pi, e, gr);

/* Make sure that the numbers are assigned correctly and print them.
One way to do this is to set them to a default value and check it.
Determine how many numbers are assigned incorrectly,
and print the error message specified in the sample output. */

return 0;
}
This is what your output should look like.
Example 1:
Result:
pi = 3.14
e = 2.718
golden ratio: 1.618
Example 2:
Result:
Oops, something is wrong. Two of the numbers were assigned incorrectly.

much appreciated
 
Old 09-22-2012, 09:57 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Can you explain what you don't understand? The explanation provided by your instructor seems, to me, to be very clear.
 
Old 09-22-2012, 10:00 PM   #3
carlosk711
Member
 
Registered: Sep 2012
Posts: 52

Original Poster
Rep: Reputation: Disabled
I don't understand what we are supposed to do in general, can you explain it to me?? I'm just beginning so I don't understand what to do
 
Old 09-22-2012, 10:02 PM   #4
carlosk711
Member
 
Registered: Sep 2012
Posts: 52

Original Poster
Rep: Reputation: Disabled
what exctly is a fill command?
 
Old 09-22-2012, 10:05 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001Reputation: 2001
Quote:
Originally Posted by carlosk711 View Post
what exctly is a fill command?
As your instructor said in the instructions, it's just a dummy call to a function that you need to write.
 
Old 09-22-2012, 10:07 PM   #6
carlosk711
Member
 
Registered: Sep 2012
Posts: 52

Original Poster
Rep: Reputation: Disabled
so what does the function do? reads that out?
is there any cin's?
 
Old 09-22-2012, 10:09 PM   #7
carlosk711
Member
 
Registered: Sep 2012
Posts: 52

Original Poster
Rep: Reputation: Disabled
so basically, the users inputs the values of pi, e, and gr? the function then verfies if they are correct? and if they are it reads out the values they already entered?
 
Old 09-22-2012, 11:44 PM   #8
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by carlosk711 View Post
so basically, the users inputs the values of pi, e, and gr? the function then verfies if they are correct? and if they are it reads out the values they already entered?
No, there's no "user input" involved. YOU, in the code you write, specify the values of the arguments. Then YOU write a fill function that verifies that you specified the values correctly.

You should probably consider an #include <math.h> in your code so you have the "real" values of M_PI and M_E available for use in your fill function. (The "golden ratio," (1+sqrt(5))/2, you'll need to compute yourself.) Oh, and a #include <stdio.h> so you can write out your answers.

Note: I'm ASSUMING (from what you posted) that this assignment is for C code, not C++ code.

Last edited by PTrenholme; 09-22-2012 at 11:48 PM.
 
Old 09-23-2012, 09:25 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,131

Rep: Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347Reputation: 1347
There are two things that make no sense at all in this assignment:

1. "you will modify the values of the arguments to a function in that function"
If the fill() function is doing the checking, why would it be modifying the values? If, as implied by the name, the fill() function is supposed to be filling in the values, then the way it is shown as being called from main() is wrong because the parameters are being passed by value and there is no way to pass the changes back to main().
2. The variables are declared as integer, but the values in the sample output are floating point.

I hope that whoever wrote that assignment is not that sloppy when writing code.
 
  


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
what is fgl_glxgears supposed to look like? veritas Linux - Software 6 01-08-2006 02:58 PM
slackware is supposed to be hard? Kahless LinuxQuestions.org Member Success Stories 16 06-10-2005 04:49 PM
who are supposed to NAT in an Internet? cranium2004 Linux - Networking 1 05-13-2005 07:19 AM
I know I'm not supposed to do this but meh Mr. Hill *BSD 16 02-28-2005 01:05 PM
How am I supposed to install xmms Otaking Linux - Newbie 4 04-08-2004 03:43 PM


All times are GMT -5. The time now is 11:37 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