LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-29-2016, 10:15 AM   #1
Minty-One
LQ Newbie
 
Registered: Dec 2015
Distribution: Arch Linux
Posts: 12

Rep: Reputation: Disabled
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.
 
Old 03-29-2016, 10:24 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
What language?

https://www.linuxquestions.org/quest...#faq_lqwelcome
 
Old 03-29-2016, 10:26 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Minty-One View Post
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.
 
Old 03-29-2016, 10:45 AM   #4
Minty-One
LQ Newbie
 
Registered: Dec 2015
Distribution: Arch Linux
Posts: 12

Original Poster
Rep: Reputation: Disabled
C

It is C language and i meant user defined functions instead of declaring variables
 
Old 03-29-2016, 10:46 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I am curious as to what numbers are being used as variables?? Most languages do not allow variable names to be or even start (for many) with a number.
 
Old 03-29-2016, 10:52 AM   #6
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by Minty-One View Post
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.
 
Old 03-29-2016, 11:17 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
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.
 
Old 03-29-2016, 11:25 AM   #8
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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?
 
Old 03-29-2016, 11:36 AM   #9
Minty-One
LQ Newbie
 
Registered: Dec 2015
Distribution: Arch Linux
Posts: 12

Original Poster
Rep: Reputation: Disabled
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!
 
Old 03-29-2016, 11:41 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Relax, you don't have to use any linux-specific features to solve this riddle. Here is something to start with:

Code:
/* hwork5.c */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static void br (void);
static void ic (void);

int main (void)
{
    ...
    return 0;
}

static void br (void)
{
    ...
}

static void ic (void)
{
    ...
}
 
Old 03-29-2016, 11:44 AM   #11
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by Minty-One View Post
i just don't have the patience to put up with the bullshit!
Thanks for correcting me.
(Note to self)

Last edited by Michael Uplawski; 03-29-2016 at 11:46 AM.
 
1 members found this post helpful.
Old 03-29-2016, 12:25 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
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.
 
2 members found this post helpful.
Old 03-29-2016, 12:33 PM   #13
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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??
 
1 members found this post helpful.
Old 03-29-2016, 12:55 PM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
Old 03-29-2016, 03:12 PM   #15
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
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.
Ah. You think the problem boils down to using quote-marks. I had not thought that far. ;-)
 
  


Reply

Tags
defined, programming language, variables



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
User defined linux commands in a user defined shell Sushma05 Linux - Newbie 3 09-13-2013 07:21 AM
[SOLVED] strange output for printf in C with user defined functions lleb Programming 3 06-16-2013 01:15 AM
[SOLVED] building coreutils... functions already defined frozenQueue Programming 8 09-16-2010 09:24 PM
FYI: Creating User Defined Functions for MySQL mchirico LinuxQuestions.org Member Success Stories 1 06-11-2004 08:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:51 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
Open Source Consulting | Domain Registration