Rosetta Code:Village Pump/: Difference between revisions

From Rosetta Code
Content added Content deleted
(basic question)
 
No edit summary
Line 1: Line 1:
{{Vptopic
{{Vptopic
|topic=i have a doubt based on c loops programming (im beginner)
|topic=binary digits
|summary= in do while loop why we assign (-1) to count in the below programming
|summary=easy - I seek if an existing task covers returning the bit count for/from the unicode of a string. Thanks ...--[[User:Billymac00|Billymac00]] ([[User talk:Billymac00|talk]]) 17:08, 19 January 2014 (UTC)
}}
}}
#include <stdio.h>
#include <ctype.h>
#define EOL '\n'
main()
{
char letter[80];
int tag, count =-1;
do ++count;
while ((letter[count]=getchar()) != EOL);
tag = count;
count=0;
do{
putchar(toupper(letter[count]));
++count;
}
while(count<tag);

}


in do while loop why we assign (-1) to count in the below programming.... could you assist me to overcome this problem..

Revision as of 03:36, 21 April 2018

'
This is a particular discussion thread among many which consider Rosetta Code.

Summary

in do while loop why we assign (-1) to count in the below programming

Discussion

  1. include <stdio.h>
  2. include <ctype.h>
  3. define EOL '\n'
 main()

{

  char letter[80];
  int tag, count =-1;
  do ++count;
  while ((letter[count]=getchar()) != EOL);
  tag = count;
  count=0;
  do{
   putchar(toupper(letter[count]));
   ++count;
  }
   while(count<tag);

}


in do while loop why we assign (-1) to count in the below programming.... could you assist me to overcome this problem..