Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Counter in C
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
guopeter




PostPosted: Mon Feb 04, 2008 1:53 pm   Post subject: Counter in C

Hi, I'm having difficulty programming a switch counter.

Basically what I need is a program that adds 1 to the variable every time a switch goes from 1 to 0 and 0 to 1.

Now it's getting frustrating..
So if anyone can help that'll be greatly appreciated!!!
THANKS!!!
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Mon Feb 04, 2008 5:27 pm   Post subject: RE:Counter in C

C:

int count = 0;
int flip = 0, old_flip=0;
while(true)
{
    if( flip != old_flip )
    {
        count++;
        old_flip = flip;
    }
}


Is that what you mean? Clearly something would have to be added to cause flip to change in my example... I didn't write that Razz
Parliam




PostPosted: Wed May 28, 2008 11:11 am   Post subject: Re: Counter in C

int count=0;
int variable_number=0;
for(i=0;i<variable_number;i++)
{
variable_number=i;
count+=1;

}


the program's have express your means ??
md




PostPosted: Thu May 29, 2008 8:51 pm   Post subject: RE:Counter in C

Parliam, this thread is kinda old and we frown on reviving old threads.

Also, your code does not work; give it a try in a debugger and you'll see why Wink
Parliam




PostPosted: Tue Jun 03, 2008 5:59 am   Post subject: RE:Counter in C

okay,i have seen the results,thz!!
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: