C & FPC

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:

01
02
#include
03
#include
04
 
05
int main(int argc, char *argv[])
06
{
07
long hh, mm,th, tm, ts;
08
 
09
printf("Reveil a quelle heure(24) minutes? \t");
10
scanf("%ld", &hh);
11
scanf("%ld", &mm);
12
 
13
th= hh+24; //ceci pr une journee
14
tm = 60 - mm;
15
ts=0;
16
while(th>=hh)
17
{
18
if(ts>0){ts-=1; sleep(1000);}
19
else if(tm>0){ts=60; tm--;}
20
else if (th>hh){ts=60; tm=60; th--;}
21
else if (th=hh){if(ts>0){ts--;}}
22
system("cls");
23
printf("%ld : %ld : %ld", th, tm, ts);
24
 
25
}
26
 
27
system("PAUSE");
28
return 0;
29
}
30
 
31
<span style="text-decoration: line-through;">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</span><span id="more-108"></span>
32
 
33
Here's the correction of the whole shebang:
34
 
35
<code lang="c">#include
36
#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(“\n\n\n Reveille toi !!!!”); system(“PAUSE”); return 0;}
}

system(“CLS”);

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

}

system(“PAUSE”);
return 0;
}