Talk:C Programming/Program flow control
Add topic| This is the discussion page for discussing improvements to the C Programming/Program flow control page. | |||
Textbook policies
|
|||
| Archives: 1 | |||
interesting bit of code
[edit source]I'm not sure how to write about this for a beginner, but some mention should be made:
// this example assumes a 32-bit size_t
#include <stdio.h>
int main(int argc, char *argv[]){
long long t = (argc) ? -1 : sizeof argv;
long long i;
if(argc) i = -1;
else i = sizeof argv;
return printf("t:%llx i:%llx\n",t,i);
}
I get this:
t:ffffffff i:ffffffffffffffff
This has to do with type promotion. The tertiary operator version is definitely not an exact substitute for the if...else version.
Perhaps just say "mixing signed and unsigned can be bad, and remember that sizeof returns a size_t"?
AlbertCahalan 03:40, 29 September 2005 (UTC)
C programme to find the area of the Triangle:
- include <stdio.h>
main (void) { float Base,Height,Area; printf("Base:"); scanf("%Base'\"); printf("Height:");
Example at end of page
[edit source]What is the example at the end of the page in aid of? It seems it should be demonstrating use of goto; or at least the topic of the chapter. However, I fail to see its relevance. I suggest it be deleted.
V-a-xvi (talk) 03:29, 23 November 2010 (UTC)
- Deleted. huntertur (discuss • contribs) 00:23, 10 November 2025 (UTC)
for loop image
[edit source]Hi. I have found this image : File:C language for.png . Is it bad image ? ( increment should be done also after last check of condition ) Am I right ? Regards --Adam majewski (discuss • contribs) 14:41, 17 March 2012 (UTC)
- Added this now, thank you! huntertur (discuss • contribs) 00:26, 10 November 2025 (UTC)