Why teach C using scanf without talking about command line arguments?Should I teach modern web development in an introductory programming course? How?Is it okay to teach C++ to my 7 year old brother?Why do educators not set an upper bound for the amount of times we're allowed to compile code?Why and how is it efficient to process sorted arrays than unsorted arrays?Students seem to be unable to use code to express their ideas. Is the teaching methodology improvable?How to teach C++ language to beginners of (BSCS) students who have no any idea about it?How can I improve other programming languages while having command on one languageWhy Computer Science students learn Digital Logic Design?Why do computer science students learn electronics and electric circuit analysis?How to teach so that your student doesn't feel stupid?
Which GPUs to get for Mathematical Optimization (if any)?
What could make large expeditions ineffective for exploring territory full of dangers and valuable resources?
When designing an adventure, how can I ensure a continuous player experience in a setting that's likely to favor TPKs?
Demographic consequences of closed loop reincarnation
Why does a tetrahedral molecule like methane have a dipole moment of zero?
Locked-up DOS computer beeped on keypress. What mechanism caused that?
How can I help our ranger feel special about her beast companion?
An entire function all whose forward orbits are bounded
"Je suis petite, moi?", purpose of the "moi"?
How slow can a car engine run?
Change Opacity of Style
Amira L'Akum not on Shabbat
Do dragons smell of lilacs?
Why is the Intel 8086 CPU called a 16-bit CPU?
How to draw a winding on a toroid of a circular cross section?
What causes a rotating object to rotate forever without external force—inertia, or something else?
Random piece of plastic
How to tell the object type of an Attachment
Software need db owner permission to master database (sql2016)
Difference between c++14 and c++17 using: `*p++ = *p`
How to interpret a promising preprint that was never published?
Is straight-up writing someone's opinions telling?
How would thermophilic fish survive?
Is encryption still applied if you ignore the SSL certificate warning for self signed?
Why teach C using scanf without talking about command line arguments?
Should I teach modern web development in an introductory programming course? How?Is it okay to teach C++ to my 7 year old brother?Why do educators not set an upper bound for the amount of times we're allowed to compile code?Why and how is it efficient to process sorted arrays than unsorted arrays?Students seem to be unable to use code to express their ideas. Is the teaching methodology improvable?How to teach C++ language to beginners of (BSCS) students who have no any idea about it?How can I improve other programming languages while having command on one languageWhy Computer Science students learn Digital Logic Design?Why do computer science students learn electronics and electric circuit analysis?How to teach so that your student doesn't feel stupid?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
Most of the books I read give examples using printf and scanf. At some point the students know perfectly how to use these two functions but they don't know about stdin, stdout and argv.
To me and according to many programming principles (e.g. KISS) a program should not interrupt the execution for prompting the user. Instead, and this is a much clever approach, the developer should learn to use the power of pipes and use the options and the arguments.
I think this:
$ whatdaywas 1982 02 16
Monday
Is much better than:
$ whatdaywas
Enter a year: 1982
Enter a month: 2
Enter a day: 16
It was a Monday.
Is there any rationale behind this pedagogical approach?
programming c
$endgroup$
add a comment |
$begingroup$
Most of the books I read give examples using printf and scanf. At some point the students know perfectly how to use these two functions but they don't know about stdin, stdout and argv.
To me and according to many programming principles (e.g. KISS) a program should not interrupt the execution for prompting the user. Instead, and this is a much clever approach, the developer should learn to use the power of pipes and use the options and the arguments.
I think this:
$ whatdaywas 1982 02 16
Monday
Is much better than:
$ whatdaywas
Enter a year: 1982
Enter a month: 2
Enter a day: 16
It was a Monday.
Is there any rationale behind this pedagogical approach?
programming c
$endgroup$
add a comment |
$begingroup$
Most of the books I read give examples using printf and scanf. At some point the students know perfectly how to use these two functions but they don't know about stdin, stdout and argv.
To me and according to many programming principles (e.g. KISS) a program should not interrupt the execution for prompting the user. Instead, and this is a much clever approach, the developer should learn to use the power of pipes and use the options and the arguments.
I think this:
$ whatdaywas 1982 02 16
Monday
Is much better than:
$ whatdaywas
Enter a year: 1982
Enter a month: 2
Enter a day: 16
It was a Monday.
Is there any rationale behind this pedagogical approach?
programming c
$endgroup$
Most of the books I read give examples using printf and scanf. At some point the students know perfectly how to use these two functions but they don't know about stdin, stdout and argv.
To me and according to many programming principles (e.g. KISS) a program should not interrupt the execution for prompting the user. Instead, and this is a much clever approach, the developer should learn to use the power of pipes and use the options and the arguments.
I think this:
$ whatdaywas 1982 02 16
Monday
Is much better than:
$ whatdaywas
Enter a year: 1982
Enter a month: 2
Enter a day: 16
It was a Monday.
Is there any rationale behind this pedagogical approach?
programming c
programming c
edited 3 hours ago
Buffy
24.9k9 gold badges42 silver badges86 bronze badges
24.9k9 gold badges42 silver badges86 bronze badges
asked 9 hours ago
nowoxnowox
1434 bronze badges
1434 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
I think that the rationale is so you don't have to introduce arrays and array notation on day 1. Typically, arrays enter into the picture at roughly the same time as loops, which would take place a few weeks or months later, depending on the pacing of your course.
That said, if you want to start with command line programs, it's not a huge problem to do so. At the very, very beginning of programming, there are always a few magical incantations that students must type, but won't fully explore until later. args[0] could easily be such an incantation.
As a side benefit to this approach, your students may have an easier time when they come to arrays, since they've already used them a bit.
$endgroup$
1
$begingroup$
I like theincantationterm you use.
$endgroup$
– nowox
6 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
add a comment |
$begingroup$
Ultimately they need to understand both ways. Which you do first seems to be a matter of preference - or maybe just following the textbook.
They need to understand at some point that 'main' in C is an interface with the OS. But, since you can't teach everything at once, you have do pick the order of instruction. But teaching command line params later can give you a way to talk about "elegance" in program design.
Of course, the program written to accept args needs to behave properly if none (or too few) are presented. Often this defaults to prompting for data in simple programs.
$endgroup$
add a comment |
$begingroup$
Because, traditionally, programs iterate over data. See JSP.
Admittedly, prompting the user for data is weird, however we're talking about beginners here, having them try to remember what the different fields of data they have to enter isn't the point of the exercise, and is likely to make them view interacting with computers as needlessly complicated. As a bonus, prompting for the values helps make the beginner programs self documenting - the text of the prompt is an explanation of the variable that is to be read - so this will hopefully help our novice programmers understand the simple program without introducing the complex topic of comments.
(fun fact: originally in pascal it wasn't legitimate code to output before input, so you couldn't prompt for input. This was quickly abandoned)
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "678"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcseducators.stackexchange.com%2fquestions%2f5820%2fwhy-teach-c-using-scanf-without-talking-about-command-line-arguments%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I think that the rationale is so you don't have to introduce arrays and array notation on day 1. Typically, arrays enter into the picture at roughly the same time as loops, which would take place a few weeks or months later, depending on the pacing of your course.
That said, if you want to start with command line programs, it's not a huge problem to do so. At the very, very beginning of programming, there are always a few magical incantations that students must type, but won't fully explore until later. args[0] could easily be such an incantation.
As a side benefit to this approach, your students may have an easier time when they come to arrays, since they've already used them a bit.
$endgroup$
1
$begingroup$
I like theincantationterm you use.
$endgroup$
– nowox
6 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
add a comment |
$begingroup$
I think that the rationale is so you don't have to introduce arrays and array notation on day 1. Typically, arrays enter into the picture at roughly the same time as loops, which would take place a few weeks or months later, depending on the pacing of your course.
That said, if you want to start with command line programs, it's not a huge problem to do so. At the very, very beginning of programming, there are always a few magical incantations that students must type, but won't fully explore until later. args[0] could easily be such an incantation.
As a side benefit to this approach, your students may have an easier time when they come to arrays, since they've already used them a bit.
$endgroup$
1
$begingroup$
I like theincantationterm you use.
$endgroup$
– nowox
6 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
add a comment |
$begingroup$
I think that the rationale is so you don't have to introduce arrays and array notation on day 1. Typically, arrays enter into the picture at roughly the same time as loops, which would take place a few weeks or months later, depending on the pacing of your course.
That said, if you want to start with command line programs, it's not a huge problem to do so. At the very, very beginning of programming, there are always a few magical incantations that students must type, but won't fully explore until later. args[0] could easily be such an incantation.
As a side benefit to this approach, your students may have an easier time when they come to arrays, since they've already used them a bit.
$endgroup$
I think that the rationale is so you don't have to introduce arrays and array notation on day 1. Typically, arrays enter into the picture at roughly the same time as loops, which would take place a few weeks or months later, depending on the pacing of your course.
That said, if you want to start with command line programs, it's not a huge problem to do so. At the very, very beginning of programming, there are always a few magical incantations that students must type, but won't fully explore until later. args[0] could easily be such an incantation.
As a side benefit to this approach, your students may have an easier time when they come to arrays, since they've already used them a bit.
answered 7 hours ago
Ben I.♦Ben I.
18.7k7 gold badges43 silver badges109 bronze badges
18.7k7 gold badges43 silver badges109 bronze badges
1
$begingroup$
I like theincantationterm you use.
$endgroup$
– nowox
6 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
add a comment |
1
$begingroup$
I like theincantationterm you use.
$endgroup$
– nowox
6 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
1
1
$begingroup$
I like the
incantation term you use.$endgroup$
– nowox
6 hours ago
$begingroup$
I like the
incantation term you use.$endgroup$
– nowox
6 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
$begingroup$
Can't you still talk about stdin/stdout/stderr without using the argv array? I believe that scanf still just reads from stdin, so you can easily store stdin to a variable.
$endgroup$
– thesecretmaster♦
3 hours ago
add a comment |
$begingroup$
Ultimately they need to understand both ways. Which you do first seems to be a matter of preference - or maybe just following the textbook.
They need to understand at some point that 'main' in C is an interface with the OS. But, since you can't teach everything at once, you have do pick the order of instruction. But teaching command line params later can give you a way to talk about "elegance" in program design.
Of course, the program written to accept args needs to behave properly if none (or too few) are presented. Often this defaults to prompting for data in simple programs.
$endgroup$
add a comment |
$begingroup$
Ultimately they need to understand both ways. Which you do first seems to be a matter of preference - or maybe just following the textbook.
They need to understand at some point that 'main' in C is an interface with the OS. But, since you can't teach everything at once, you have do pick the order of instruction. But teaching command line params later can give you a way to talk about "elegance" in program design.
Of course, the program written to accept args needs to behave properly if none (or too few) are presented. Often this defaults to prompting for data in simple programs.
$endgroup$
add a comment |
$begingroup$
Ultimately they need to understand both ways. Which you do first seems to be a matter of preference - or maybe just following the textbook.
They need to understand at some point that 'main' in C is an interface with the OS. But, since you can't teach everything at once, you have do pick the order of instruction. But teaching command line params later can give you a way to talk about "elegance" in program design.
Of course, the program written to accept args needs to behave properly if none (or too few) are presented. Often this defaults to prompting for data in simple programs.
$endgroup$
Ultimately they need to understand both ways. Which you do first seems to be a matter of preference - or maybe just following the textbook.
They need to understand at some point that 'main' in C is an interface with the OS. But, since you can't teach everything at once, you have do pick the order of instruction. But teaching command line params later can give you a way to talk about "elegance" in program design.
Of course, the program written to accept args needs to behave properly if none (or too few) are presented. Often this defaults to prompting for data in simple programs.
answered 8 hours ago
BuffyBuffy
24.9k9 gold badges42 silver badges86 bronze badges
24.9k9 gold badges42 silver badges86 bronze badges
add a comment |
add a comment |
$begingroup$
Because, traditionally, programs iterate over data. See JSP.
Admittedly, prompting the user for data is weird, however we're talking about beginners here, having them try to remember what the different fields of data they have to enter isn't the point of the exercise, and is likely to make them view interacting with computers as needlessly complicated. As a bonus, prompting for the values helps make the beginner programs self documenting - the text of the prompt is an explanation of the variable that is to be read - so this will hopefully help our novice programmers understand the simple program without introducing the complex topic of comments.
(fun fact: originally in pascal it wasn't legitimate code to output before input, so you couldn't prompt for input. This was quickly abandoned)
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
Because, traditionally, programs iterate over data. See JSP.
Admittedly, prompting the user for data is weird, however we're talking about beginners here, having them try to remember what the different fields of data they have to enter isn't the point of the exercise, and is likely to make them view interacting with computers as needlessly complicated. As a bonus, prompting for the values helps make the beginner programs self documenting - the text of the prompt is an explanation of the variable that is to be read - so this will hopefully help our novice programmers understand the simple program without introducing the complex topic of comments.
(fun fact: originally in pascal it wasn't legitimate code to output before input, so you couldn't prompt for input. This was quickly abandoned)
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
Because, traditionally, programs iterate over data. See JSP.
Admittedly, prompting the user for data is weird, however we're talking about beginners here, having them try to remember what the different fields of data they have to enter isn't the point of the exercise, and is likely to make them view interacting with computers as needlessly complicated. As a bonus, prompting for the values helps make the beginner programs self documenting - the text of the prompt is an explanation of the variable that is to be read - so this will hopefully help our novice programmers understand the simple program without introducing the complex topic of comments.
(fun fact: originally in pascal it wasn't legitimate code to output before input, so you couldn't prompt for input. This was quickly abandoned)
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
Because, traditionally, programs iterate over data. See JSP.
Admittedly, prompting the user for data is weird, however we're talking about beginners here, having them try to remember what the different fields of data they have to enter isn't the point of the exercise, and is likely to make them view interacting with computers as needlessly complicated. As a bonus, prompting for the values helps make the beginner programs self documenting - the text of the prompt is an explanation of the variable that is to be read - so this will hopefully help our novice programmers understand the simple program without introducing the complex topic of comments.
(fun fact: originally in pascal it wasn't legitimate code to output before input, so you couldn't prompt for input. This was quickly abandoned)
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 5 mins ago
GrumpGrump
101
101
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Grump is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Thanks for contributing an answer to Computer Science Educators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcseducators.stackexchange.com%2fquestions%2f5820%2fwhy-teach-c-using-scanf-without-talking-about-command-line-arguments%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown