NO

Author Topic: nead help :-)  (Read 4611 times)

copex

  • Guest
nead help :-)
« on: April 02, 2007, 04:16:44 PM »
Hi

im trying to write a program for my pda to dispaly a 4 digit code based on the input from the
user, ive got the GUI side working i just nead hepl with the maths side....

A1 = 10
A2 = 20
H = 7

Z = (A1A2 * (H++)) * 2

result neads to show the last 4 digits of Z

(i.e)-----------------------

Z = 1020 x 7
Z * 2

 = 14280

result 4280
---------------------------

thank you for takeing the time to read this.....

cane

  • Guest
Re: nead help :-)
« Reply #1 on: April 02, 2007, 05:08:13 PM »
result = Z % 10000

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: nead help :-)
« Reply #2 on: April 03, 2007, 10:42:32 AM »
Code: [Select]
int A1 = 10;
int A2 = 20;
int H = 7;
int Z;

char *sample(void)
{
    static char string[256];

    Z = (((A1*100)+A2) * (H++)) * 2
    sprintf(string,"%d", Z);
    return (string + (strlen(string) - 4));
}
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

copex

  • Guest
Re: nead help :-)
« Reply #3 on: April 03, 2007, 06:32:23 PM »
Thank you,

for the help, most intresting, ill give it a try