Jump to content

Talk:C Programming/Program flow control

Page contents not supported in other languages.
Add topic
From Wikibooks, open books for an open world
Latest comment: 21 days ago by Huntertur in topic for loop image

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)Reply

C programme to find the area of the Triangle:


  1. 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)Reply

Deleted. huntertur (discusscontribs) 00:23, 10 November 2025 (UTC)Reply

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 (discusscontribs) 14:41, 17 March 2012 (UTC)Reply

Added this now, thank you! huntertur (discusscontribs) 00:26, 10 November 2025 (UTC)Reply