C & FPC

Written on 29/08/2008 – 22:04 | by webscriptz |

C programming and pascal, that’s what I’m doing for the moment, I have an exam in 5 days, man I hate it.

Just finished a clock in C: you give the time for tomorrow and he’ll count it down. But it’s basic:

#include
#include

int main(int argc, char *argv[])
{
long hh, mm,th, tm, ts;

printf(“Reveil a quelle heure(24) minutes? t”);
scanf(“%ld”, &hh);
scanf(“%ld”, &mm);

th= hh+24; //ceci pr une journee
tm = 60 – mm;
ts=0;
while(th>=hh)
{
if(ts>0){ts-=1; sleep(1000);}
else if(tm>0){ts=60; tm–;}
else if (th>hh){ts=60; tm=60; th–;}
else if (th=hh){if(ts>0){ts–;}}
system(“cls”);
printf(“%ld : %ld : %ld”, th, tm, ts);

}

system(“PAUSE”);
return 0;
}

I’m more or less pleased but still the infinite refreshments aren’t what I wanted and sorry about the comment but in exercises I don’t use them

Here’s the correction of the whole shebang:

#include
#include

int main(int argc, char *argv[])
{
long hh, mm,th, tm, ts;

printf(“Reveil a quelle heure(24) minutes? t”);
scanf(“%ld”, &hh);
scanf(“%ld”, &mm);

th= hh+1; //ceci pr une journee
tm = mm;
ts=0;

while(th>=hh)
{
if(th>hh){
if(ts>0){ts-=1; sleep(1000);}
else if(tm>0){ts=60; tm–;}
else if (th>hh){ts=60; tm=60; th–;}
}
else if(th==hh){
if(ts>0){ts-=0; sleep(1000);}
else if(tm>mm){ts=60; tm–;}
else {printf(“nnn Reveille toi !!!!”); system(“PAUSE”); return 0;}
}

system(“CLS”);

printf(“%ld : %ld : %ld”, th, tm, ts);

}

system(“PAUSE”);
return 0;
}


related post

Post a Comment

About Me

Here I'll share my knowledge, discovery and experience related to my hobby and work. Most articles on this site are related to blog design, short reviews, tips and make money online. More

Find entries :