Tuesday 29 November 2011

Reading list for C.

1
Absolute beginners guide to C 2nd edition
Greg Perry
SAMS publishing


2
C / C++ annotated archives
A. Friedman, L. Klander, M. Michaelis, H. Schildt
Osborne


3
C by example special edition
Greg Perry
QUE


4
C for dummies volume one
Dan Gookin
IDG books


5
C for dummies volume two
Dan Gookin
IDG books


6
C programming in easy steps 3rd edition
Mike McGrath



7
Learning to program in C
N. Kantaris
Bernard Babani publishing LTD


8
Numerical recipes in C
W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery
Cambridge


9
Programming in C third edition
Stephen G. Kochan
Developer's library


10
Programming in Objective-C 2.0 second edition
Stephen G. Kochan
Developer's library


11
Simple C
Jim McGregor, Richard McGregor, Alan Watt
Addison-Wesley


12
The C programming language second edition
Brain W. Kernighan and Dennis M. Ritchie
Prentice Hall Software series


13
The complete reference C fourth edition
Herbert Schildt
Osborne

Monday 7 November 2011

A countdown timer written in C

/***************************************************************************
 *   Copyright (C) 2009 by David Ronald Smith,,,   *
 *   david@debian   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#define DELAY 1000000000
int hcount;
int mcount;
int scount;
void delay(void);

int main(void)
{
printf("input the hours ");
scanf("%d", &hcount);
printf("input the minutes ");
scanf("%d", &mcount);
printf("input the seconds ");
scanf("%d", &scount);

for(;;)
{
scount--;

if(scount==-1) {
scount =59;
mcount--;
}

if(mcount== -1){
mcount=59;
hcount--;
}

if(hcount==0 && mcount==0 && scount==0){
break;
}
delay();
printf("\n%i\n", scount);
printf("\n%i\n", mcount);
printf("\n%i\n", hcount);
}
return 0;
}

void delay(void)
{
long int t;
for(t=1; t<DELAY; ++t);
}

Saturday 5 November 2011

A lottery program written in C

 #include<stdlib.h>
 #include<time.h>
 #include<stdio.h>

 void main()
 {
 int numbers[49];
 int ball, run, i, j, k, flag;
 run = 0;
 ball = 0;
 for(k=1; k<=49; k++)
  numbers[k] = '\0';
 printf("Here are your lottery numbers.\n");
 do
 {
 srand((unsigned)time(NULL));
 ball = rand()%49 + 1;
 flag =0;
 if(ball == numbers[ball])
 {
 flag = 1;
 }
 if(flag==0)
 {
 numbers[ball] = ball;
 run = run + 1;
 printf("%i\n",ball);
 }
 } while(run <= 6);
 }