Question:
Statement vs Instruction vs Command in C language?
Shiv
2016-02-01 08:26:52 UTC
Statement vs Instruction vs Command in C language?
Three answers:
husoski
2016-02-01 09:48:54 UTC
C has nothing that it calls "instructions". A C source file is made up of C language declarations (which may contains statements) and "preprocessor directives".



Source lines that begin with a # character that is not part of a multiple-line comment are preprocessor directives. The preprocessor chooses which lines to compile, allows lines to be included from another source file, and filters C language lines for macro replacements. Since "directive" is a synonym for "command", I suppose you could think of these directives as commands, but none of the official documentation uses that term.



The C program is what's left after the preprocessor is done. It consists of declarations, some of which are also definitions. C declarations declare types, objects (aka "variables") and functions.



A C statement specifies some action to be performed, and only occurs in the body of a function definition. Period. There's a casual misunderstanding, mostly from terminology used with other languages I think, that a statement is "anything ending with a semicolon". That's not how the C standard defines the language, but you will see "declaration statements" being used, even though that's a contradiction. (...including by me.)



I'm not a sticky-formalist, so any language that gets the point across works for me. I do believe, though, that you should understand what the words mean before you start misusing them. :^)
anonymous
2016-12-16 19:26:38 UTC
C Language Commands
roger
2016-02-01 08:50:54 UTC
C has no "commands"

Statements like

a=c+2; ends in a ;

instruction "add 2 to c"

c+2 actually an expression



C also has functions and keywords.

and preprocessor directives.



{Statements do not always have to end in a ; if they are in an if or while..

if(c=c+2){}

or

while(c=c+2){}

but that is not good practice...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...