User Defined Functions with words instead of intergers
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
User Defined Functions with words instead of intergers
Would someone steer me in the right direction with solving this problem ? I see variables declared everywhere but it is always with numbers and not words such as in this problem below
5. Write a program that produces the following output:
Brazil, Russia, India, China
India, China,
Brazil, Russia
Have the program use two user-defined functions in addition to main() : one named
br() that prints “Brazil, Russia” once, and one named ic() that prints “India, China”
once. Let main() take care of any additional printing tasks.
Would someone steer me in the right direction with solving this problem ? I see variables declared everywhere but it is always with numbers and not words such as in this problem below
You don't need to declare any variables to solve this problem.
Would someone steer me in the right direction with solving this problem ? I see variables declared everywhere but it is always with numbers and not words such as in this problem below
You must show us how you declared your variables and how you initialized them. I am unable do deduce from your description, what may lead to the observed program behaviour and cannot even say, if the result can be expected or not. However. Most of the time, that the data-type is unexpected (e.g. an Integer instead of a String or char-array, if you prefer), a false declaration is a probable and an unintentional or faulty type-cast the improbable cause.
Show us the code!
Because, otherwise, you get answers like this which do probably not help: --->Code example removed<----
Last edited by Michael Uplawski; 03-29-2016 at 11:26 AM.
Per the LQ Rules, please 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 Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
Your not helping the OP learn by providing the answers.
Your not helping the OP learn by providing the answers.
Right, but I still have a doubt. If the problem description is badly written, however, I beg your pardon that my example may have matched. Do you really think so?
Not a homework assignment it's just a hobby but i really don't have the time to deal with smart ass comments and rediculous rules. And people wonder why only one percent of the population uses linux especuially arch. It's the supriority complex people have associated with linux and arch especially so thanks to the people that tried to help but i'll be leaving now i just don't have the patience to put up with the bullshit!
I am sorry that you think rules are ridiculous and it was not meant to be a smart ass comment. Unless you provide us with more information and a little background we have no idea and no one here is a mind reader.
I am going to guess OP is another unsatisfied Windows user who thinks everyone should tell them the answers as that is what they paid for ... oh wait??
This homework-problem is as clear as it could be: you're "over-thinking it."
Many languages do have a formal notion of "enumerated types" such that you can assign color := red and, when you print color you get red. But you don't need to do this with this homework problem. All they want are two functions that each print a particular fixed string.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.